Unity開發游戲使用XLua的基礎

Unity使用Xlua的常用編碼方式,做一下記錄

1、C#調用lua

1、Lua解析器

private LuaEnv env = new LuaEnv();//保持它的唯一性void Start(){env.DoString("print('你好lua')");//env.DoString("require('Main')");  默認在resources文件夾下面//幫助我們清除lua中我們沒有手動釋放的對象  垃圾回收env.Tick();//銷毀lua解釋器,用的較少env.Dispose();}

2、自定義loader

    private void Start(){//xlua路徑重定向方法_env.AddLoader(MyLoader);_env.DoString("require('Main')");}private byte[] MyLoader(ref string filepath){//傳入的filepath是 require執行的lua腳本文件名,在這里是mainstring path = Application.dataPath + "/Lua/" + filepath + ".lua";//判斷文件是否存在if (File.Exists(path)){return File.ReadAllBytes(path);}else{Debug.Log("重定向失敗,文件名為"+filepath);}return null;}

3、Lua管理器

/// <summary>
/// lua管理器
/// 提供lua解析器
/// 保證解析器的唯一性
/// </summary>
public class LuaMgr
{private static LuaMgr _instance;public static LuaMgr Instance{get{if (_instance==null){_instance = new LuaMgr();}return _instance;}}private LuaEnv _luaEnv;/// <summary>/// 得到lua中的_G/// </summary>public LuaTable Gloabl => _luaEnv.Global;/// <summary>/// 初始化/// </summary>public void Init(){if (_luaEnv!=null) return;_luaEnv = new LuaEnv();_luaEnv.AddLoader(MyLoader);_luaEnv.AddLoader(MyABLoader);}#region 標準內容/// <summary>/// 傳入文件名,執行腳本/// </summary>/// <param name="fileName"></param>public void DoLuaFile(string fileName){string str = $"require('{fileName}')";DoString(str);}public void DoString(string str){if(_luaEnv==null){Debug.Log("解析器未初始化");return;}_luaEnv.DoString(str);}/// <summary>/// 釋放lua垃圾/// </summary>public void Tick(){if(_luaEnv==null){Debug.Log("解析器未初始化");return;}_luaEnv.Tick();}/// <summary>/// 銷毀解析器/// </summary>public void Dispose(){if(_luaEnv==null){Debug.Log("解析器未初始化");return;}_luaEnv.Dispose();_luaEnv = null;}//自動執行private byte[] MyLoader(ref string filepath){//傳入的filepath是 require執行的lua腳本文件名,在這里是mainstring path = Application.dataPath + "/Lua/" + filepath + ".lua";//判斷文件是否存在if (File.Exists(path)){return File.ReadAllBytes(path);}else{Debug.Log("重定向失敗,文件名為"+filepath);}return null;}//重定向加載AB包中的lua腳本private byte[] MyABLoader(ref string filepath){//加載路徑string path = Application.streamingAssetsPath + "/lua";//加載AB包AssetBundle ab=AssetBundle.LoadFromFile(path); TextAsset tx = ab.LoadAsset<TextAsset>(filepath+".lua");//加載Lua文件返回//加載lua文件,byte數組return tx.bytes;}//Lua腳本最終會放在ab包中,#endregion
}

4、全局變量獲取

 private void Start(){LuaMgr.Instance.Init();LuaMgr.Instance.DoLuaFile("Main");int i= LuaMgr.Instance.Gloabl.Get<int>("testNumber");var i2= LuaMgr.Instance.Gloabl.Get<bool>("testBool");var i3= LuaMgr.Instance.Gloabl.Get<float>("testFloat");var i4= LuaMgr.Instance.Gloabl.Get<string>("testString");//值拷貝不會修改lua中的值,可以用setLuaMgr.Instance.Gloabl.Set("testNumber",1000);i= LuaMgr.Instance.Gloabl.Get<int>("testNumber");Debug.Log("testNumber"+i);}

雖然lua中只有number一種數值類型,但是我們可以根據它具體的值,用對應的C#變量類型來存儲

5、全局函數的獲取

public delegate void CustomCall();
public delegate void CustomCall2(int a);
//加一個特性,只有添加特性才能被調用,,加完特性后還要一部分工作,就是點擊Xlua->Generatedate
[CSharpCallLua]
public delegate int CustomCall3(int a);
[CSharpCallLua]   //使用out來接
public delegate int CustomCall4(int a,out int b,out bool c,out string d,out int e);[CSharpCallLua]   //使用ref來接
public delegate int CustomCall5(int a,ref int b,ref bool c,ref string d,ref int e);//變長函數,如果邊長函數中類型多種多樣,那就使用object
[CSharpCallLua]
public delegate void CustomCall6(string a,params int[] args);
public class Lesson5_CallFunction : MonoBehaviour
{ void Start(){LuaMgr.Instance.Init();// LuaMgr.Instance.DoString("require('Main')"); LuaMgr.Instance.DoLuaFile("Main");//無參無返回值var call1= LuaMgr.Instance.Gloabl.Get<UnityAction>("testFun1");call1();//有參有返回值var call2 = LuaMgr.Instance.Gloabl.Get<CustomCall3>("testFun2");// Debug.Log(call2(2));var call3 = LuaMgr.Instance.Gloabl.Get<Func<int,int>>("testFun2");// Debug.Log("Func: "+call3(2));//有參多返回值var call4 = LuaMgr.Instance.Gloabl.Get<CustomCall4>("testFun3");int b;bool c;string d;int e;//  Debug.Log(call4(51,out b,out c,out d,out e));var call5 = LuaMgr.Instance.Gloabl.Get<CustomCall5>("testFun3");int b1 = 0;bool c1 = true;string d1="";int e1=0;// Debug.Log(call5(51,ref b1,ref c1,ref d1,ref e1));var call6 = LuaMgr.Instance.Gloabl.Get<CustomCall6>("testFun4");call6("你好",1,5,6,5,4);// LuaFunction lf = LuaMgr.Instance.Gloabl.Get<LuaFunction>("testFun4");// lf.Call("你好", 1, 5, 6, 5, 4);}
print("Variable啟動")
-- 無參無返回
testFun1 = function()print("無參無返回")
end-- 有參有返回
testFun2 = function(a)print("有參有返回")return a + 1
end
-- 多返回
testFun3 = function(a)print("多返回")return 1, 2, false, "123", a
end
-- 變長參數
testFun4 = function(a, ...)print("變長參數")print(a)arg = { ... }for k, v in pairs(arg) doprint(k, v)end
end

6、List和Dictionary

 private void Start(){LuaMgr.Instance.Init();LuaMgr.Instance.DoLuaFile("Main");#region ListList<int> list = LuaMgr.Instance.Gloabl.Get<List<int>>("testList");for (int i = 0; i < list.Count; i++){Debug.Log("----"+list[i]);}//不確定類型用objectList<object> list2 = LuaMgr.Instance.Gloabl.Get<List<object>>("testList2");for (int i = 0; i < list2.Count; i++){Debug.Log("----"+list2[i]);}#endregion#region 字典Dictionary<string, int> dic = LuaMgr.Instance.Gloabl.Get<Dictionary<string, int>>("testDic");foreach (var item in dic){Debug.Log(item.Key+"____"+item.Value);}Dictionary<object, object> dic2 = LuaMgr.Instance.Gloabl.Get<Dictionary<object, object>>("testDic2");foreach (var item in dic2){Debug.Log(item.Key+"____"+item.Value);}#endregion}

7、類映射table

//Lua
testClas={testInt=2,testBool=true,testFloat=1.2,testString="123",testFun=function()print("NIHAO")end
}
//C#
public class CallLuaClass
{//在類中去生命成員變量,名字要和lua那邊一樣//注意,。一定是公有的,不然不能賦值。//這個自定義中的變量可以多也可以少public int testInt;public bool testBool;public float testFloat;public string testString;public UnityAction testFun;//方法
}
public class Lesson7_Table : MonoBehaviour
{private void Start(){LuaMgr.Instance.Init();LuaMgr.Instance.DoLuaFile("Main");CallLuaClass callLuaClass = LuaMgr.Instance.Gloabl.Get<CallLuaClass>("testClas");Debug.Log(callLuaClass.testString);callLuaClass.testFun();}
}

8、接口映射table

注意接口是引用拷貝。改了值后,lua值也會改變

//接口中不允許有成員變量
//我們用屬性
[CSharpCallLua]
public interface ICSharpCallInterface
{int testInt { get; set; }bool testBool { get; set; }float testFloat { get; set; }string testString { get; set; }UnityAction testFun { get; set; }
}public class Lesson_Interface : MonoBehaviour
{void Start(){LuaMgr.Instance.Init();LuaMgr.Instance.DoLuaFile("Main");ICSharpCallInterface callInterface = LuaMgr.Instance.Gloabl.Get<ICSharpCallInterface>("testClas");Debug.Log(callInterface.testFloat);}   
}

9、luatable映射到table

    //不過官方不建議使用luaTable和luaFunctionvoid Start(){LuaMgr.Instance.Init();LuaMgr.Instance.DoLuaFile("Main");LuaTable table = LuaMgr.Instance.Gloabl.Get<LuaTable>("testClas");Debug.Log(table.Get<int>("testInt"));table.Get<LuaFunction>("testFun").Call();table.Dispose();//使用完了dispose }

2、lua調用C#(重點)

用的較多。

1、Lua使用C#類

print("************Lua調用C#相關知識點*************")
-- lua中使用C#的類非常簡單
-- 固定套路
-- Cs.命名空間.類名
-- Unity的類,比如GameObject Transform等等  ---CS.UnityEngine.類名-- 通過C#中的類,實例化一個對象,注意lua中沒有new
-- 默認調用的相當于無參構造
local obj1 = CS.UnityEngine.GameObject()
local obj2 = CS.UnityEngine.GameObject("鄭毅")-- 為了方便使用,并且節約性能,定義全局變量儲存C#中的類
-- 相當于取了一個別名,這也是一種優化方式
GameObject = CS.UnityEngine.GameObject
local obj3 = GameObject("第三個")-- 類中的靜態對象可以直接使用 .來調用
local obj4 = GameObject.Find("鄭毅")
--得到對象中的成員變量,直接對象.就可以了
print(obj4.transform.position)
Vector3 = CS.UnityEngine.Vector3;
--使用對象中的成員方法,一定要加:
obj4.transform:Translate(Vector3.right)
print(obj4.transform.position)-- 調用自定義的類
local t = CS.Test()
t:Speak("你好")
--有命名空間的
local t = CS.MyClass.Test2()
t:Speak("你好")--繼承mono的類
--繼承mono的類是不能直接new的
--lua不支持使用無慘的泛型的
local obj5 = GameObject("加腳本測試")
-- Xlua提供了一個重要防范typeof 可以得到類的類型
obj5:AddComponent(typeof(CS.LuaCallC))

---- c#

public class Test
{public void Speak(string str){Debug.Log("test1"+str);}
}namespace MyClass
{public class Test2{public void Speak(string str){Debug.Log("test2"+str);}}
}
public class LuaCallC : MonoBehaviour
{}

2、枚舉

PrimitiveType = CS.UnityEngine.PrimitiveType
GameObject = CS.UnityEngine.GameObject
local obj = GameObject.CreatePrimitive(PrimitiveType.Cube)---獲取自定義美劇
myEnum=CS.MyEnum
local c=myEnum.Idle
print(c)
--枚舉轉換
--數值轉枚舉
local a=myEnum.__CastFrom(1)
print(a)
--字符串轉枚舉
local b=myEnum.__CastFrom("Atk ")
print(b)

3、調用C#數組和list和字典

public class Lesson
{public int[] array = new int[5] { 1, 2, 3, 4, 5 };public List<int> list = new List<int>();public Dictionary<int, string> dic = new Dictionary<int, string>();
}
local obj = CS.Lesson()
-- Lua使用數組相關知識
-- 長度
print(obj.array.Length)
print(obj.array[2])
--遍歷,雖然lua索引是從1開始
--但是要按照C#來,從0開始
for i = 0, obj.array.Length - 1 doprint(obj.array[i])
end--創建數組   數組的底層是array類,使用靜態方法CreateInstance
local array2 = CS.System.Array.CreateInstance(typeof(CS.System.Int32), 10)
print(array2.Length)---list
obj.list:Add(10)
obj.list:Add(20)
obj.list:Add(30)
obj.list:Add(40)for i = 0, obj.list.Count - 1 doprint(obj.list[i])
end
--創建list  相當于得到一個List<int>的一個類的別名,需要再實例化
local list_string = CS.System.Collections.Generic.List(CS.System.Int32)
local list3 = list_string()
list3:Add(50)
print(list3.Count)
print(list3[0])--- 字典
obj.dic:Add(1, "你好")
print(obj.dic[1])for k, v in pairs(obj.dic) doprint(k, v)
end--創建字典
local dicString=CS.System.Collections.Generic.Dictionary(CS.System.String,CS.UnityEngine.Vector3)
local dic2=dicString()
dic2:Add("001",CS.UnityEngine.Vector3.right)print(dic2["001"])---這里有個坑,自己創建的字典,這樣是訪問不到的
print(dic2:get_Item("001")) --只有通過這種方法才可以
dic2:set_Item("001",CS.UnityEngine.Vector3.up)
print(dic2:get_Item("001")) --只有通過這種方法才可以
print(dic2:TryGetValue("001"))--多返回值

4、拓展方法

//拓展方法
//拓展方法的寫法
//想要在lua中使用拓展方法,一定要在工具類前面加上特性
//如果不加該特性,除了拓展方法以外,都不會報錯
//但是lua是通過反射機制去調用C#類的,效率較低
//加上可提高性能
[LuaCallCSharp]
public static class Tools
{public static void Move(this Lesson4 obj){Debug.Log(obj.name+"移動");}
}
public class Lesson4
{public string name = "名稱";public void Speak(string str){Debug.Log(str);}public static void Eat(){Debug.Log("吃東西");}
}
public class LuaCallC : MonoBehaviour
{private void Start(){Lesson4 lesson4 = new Lesson4();lesson4.Move();//拓展方法,對象可以直接調用}
}
Lesson4 = CS.Lesson4
Lesson4.Eat()
--成員方法
local a = Lesson4()
a:Speak("說話了啊")
--使用拓展方法
a:Move()

5、ref out

public class Lesson5
{public int RefFun(int a,ref int b,ref int c,int d){b = a + d;c = a - d;return 100;}public int OutFun(int a,out int b,out int c,int d){b = a;c = d;return 200;}public int RefOutFun(int a,out int b,ref int c){b = a * 10;c = a * 20;return 300;}
}
Lesson5 = CS.Lesson5
local obj = Lesson5()--ref 參數會以多返回值的形式返回給lua
local a, b, c = obj:RefFun(1, 0, 0, 1)
print(a)
print(b)
print(c)--out 參數會以多返回值的形式返回給lua
--out參數不需要傳占位置的值
local a, b, c = obj:OutFun(1, 30)
print(a)
print(b)
print(c)--綜合起來
-- out不用占位值 ref需要占位
local a, b, c = obj:OutFun(1, 30)
print(a)
print(b)
print(c)

6、C#函數重載

public class Lesson6
{public int Cal(){return 100;}public int Cal(int a,int b){return a + b;}public int Cal(int a){return a;}public float Cal(float a){return a;}
}
Lesson6 = CS.Lesson6
local obj = Lesson6()print(obj:Cal())
print(obj:Cal(1))
print(obj:Cal(15,20))
--對于C#中多精度的重載函數支持不好
print(obj:Cal(1.25))--如果要解決重載函數模糊不清的問題
--xlua提供了解決方案,反射機制,但這種方法只做了解
--另外,能不用就不用
local m2 = typeof(CS.Lesson6):GetMethod("Cal", { typeof(CS.System.Single) })
--通過xlua提供的一個方法,把它轉換成lua函數來使用。
--一般我們轉一次,然后重復使用
local f2 = xlua.tofunction(m2)
print(f2(obj,10.2))

7、委托 事件

public class Lesson8
{public UnityAction del;public event UnityAction eventAction;public void DoEvent(){if (eventAction != null) eventAction();}
}
Lesson8 = CS.Lesson8
local obj = Lesson8()-- 委托
local func=function()print("這是lua函數")
end
-- 注意lua沒有復合運算符,沒有+=
-- 如果第一次往委托中加函數,因為是niu 不能直接+
-- 所以第一次  要先等=
obj.del=func
--第二次可以
obj.del=obj.del+func
obj.del()
--委托清除
obj.del=nil---事件,事件和委托特別不一樣
---有點類似于成員方法 
obj:eventAction("+",func)
obj:DoEvent()
--事件不能直接設置為空

8、二維數組

使用GetValue獲取


[LuaCallCSharp]
public class Book : MonoBehaviour
{public int[,] INTArray;void Awake(){INTArray = new int[3, 3]{{1,2,3},{2,4,5},{6,7,8}};}public int GetArrayValue(int x,int y){return INTArray[x, y];}public void SetArrayValue(int x,int y,int value){INTArray[x, y] = value;}
}local book = CS.Book
local go = GameObject("二維數組")local obj = go:AddComponent(typeof(book))-- 調用 GetArrayValue 方法
local c = obj:GetArrayValue(1, 1)
print(c)

9、nil

PrimitiveType=CS.UnityEngine.PrimitiveType
Rigidbody=CS.UnityEngine.Rigidbody
local GameObject = CS.UnityEngine.GameObject;
local obj = GameObject("Cube")
local obj2 = GameObject.CreatePrimitive(PrimitiveType.Cube)
local rig = obj2:GetComponent(typeof(Rigidbody))
-- nil和Null沒法進行 == 比較
if rig == nil thenprint("空啊")
end
print("不為空嗎")--可用這樣
if rig:Equals(nil) thenobj2:AddComponent(typeof(Rigidbody))
end
-- 全局函數
print(IsNull(rig))
-- 在C#中
print(rig:Equ())
-- 判斷全局函數
function IsNull(obj)if obj==nil or obj:Equals(nil) thenreturn trueendreturn false
end

10、C# 擴展方法

[LuaCallCSharp]
public static class ObjTest
{public static bool Equ(this Object obj){return obj==null;}
}

11、特殊問題

CSharpCallLua :委托、接口

LuaCallCSharp:拓展方法時、建議每個類都加

無法為系統類或者第三方庫代碼加上這兩個特性

Obj = CS.UnityEngine.GameObject
Ui = CS.UnityEngine.UI
local sid=Obj.Find("Slider")
local sliders=sid:GetComponent(typeof(Ui.Slider))
sliders.onValueChanged:AddListener(function(f)print("你好")
end)---------------------------------------------------------------
public static class Lesson10
{[CSharpCallLua]public static List<Type> cSharpCallLua = new List<Type>(){typeof(UnityAction<float>)};[LuaCallCSharp]public static List<Type> luaCallCSharp=new List<Type>(){typeof(GameObject)};
}
----------------------------------------------------------------
local ani=Obj.Find("Btn")
local btn=ani:GetComponent(typeof(Ui.Button))
btn.onClick:AddListener(function()print("鼠標點擊了")
end)---還可以這樣
local c=CS.UnityEngine.Events.UnityAction(function()print("鼠標點擊了")
end)

12、協程

--xlua提供的一個工具表,一定要通過require調用后才能用
local util=require('xlua.util')
GameObject = CS.UnityEngine.GameObject
WaitForSeconds = CS.UnityEngine.WaitForSeconds
--在場景中創建一個空物體,然后添加一個腳本
local obj = GameObject("Coroutine")
local mono = obj:AddComponent(typeof(CS.LuaCallC))
--希望用來被開啟的協程函數
fun = function()local a = 1while true docoroutine.yield(WaitForSeconds(1))print(a)a = a + 1if a>10 then--關閉協程mono:StopCoroutine(b)endend
end
--我們不能直接將lua函數傳入到開啟協程中
--如果要把lua函數當做協程函數傳入
--必須先調用xlua.util 中的cs_generator(fun)
b=mono:StartCoroutine(util.cs_generator(fun))

13、泛型

支持有約束有參數的泛型函數

不支持沒有約束的泛型番薯

不支持有約束,但是沒有參數的泛型函數

不支持非Class的約束

public class Lesson12
{public class TestFather{}public class TestChild:TestFather{}public void TestFun1<T>(T a,T b) where T:TestFather{Debug.Log("有參數有約束的泛型方法");}public void TestFun2<T>(T a,T b) {Debug.Log("有參數無約束的泛型方法");}public void TestFun3<T>(T a) {Debug.Log("有參數");}public void TestFun3<T>() where T:TestFather{Debug.Log("有參數");}  }
local obj=CS.Lesson12()
local child=CS.Lesson12.TestChild()
local father=CS.Lesson12.TestFather()------------默認情況下支持----------
--支持有約束有參數的泛型函數
obj:TestFun1(child,father)
-----------------------------------注意 如果是mono 這種方式支持使用
--但是如果是iLcpp打包 泛型參數是引用類型才可以--要使得可用用
--設置泛型類型再使用
local testFun2=xlua.get_generic_method(CS.Lesson12,"TestFun3")
local testFun2_R=testFun2(CS.System.Int32)
--調用
testFun2_R(obj,10)--設置泛型類型再使用
local testFun3=xlua.get_generic_method(CS.Lesson12,"TestFun2")
local testFun3_R=testFun3(CS.System.Int32)
--調用
testFun3_R(obj,10,20)

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/67697.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/67697.shtml
英文地址,請注明出處:http://en.pswp.cn/web/67697.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

筆記:使用ST-LINK燒錄STM32程序怎么樣最方便?

一般板子在插件上&#xff0c; 8腳 3.3V;9腳 CLK;10腳 DIO;4腳GND ST_Link 19腳 3.3V;9腳 CLK;7腳 DIO;20腳 GND 燒錄軟件&#xff1a;ST-LINK Utility&#xff0c;Keil_5; ST_Link 接口針腳定義&#xff1a; 按定義連接ST_Link與電路板&#xff1b; 打開STM32 ST-LINK Uti…

網絡測試工具

工具介紹&#xff1a; 這是一個功能完整的網絡測速工具&#xff0c;可以測試網絡的下載速度、上傳速度和延遲。 功能特點&#xff1a; 1. 速度測試 - 下載速度測試 - 上傳速度測試 - Ping延遲測試 - 自動選擇最佳服務器 2. 實時顯示 - 進度條顯示測試進度 - 實時顯示測試狀…

java每日精進1.31(SpringSecurity)

在所有的開發的系統中&#xff0c;都必須做認證(authentication)和授權(authorization)&#xff0c;以保證系統的安全性。 一、基礎使用 1.依賴 <dependencies><!-- 實現對 Spring MVC 的自動化配置 --><dependency><groupId>org.springframework.bo…

簡單的SQL語句的快速復習

語法的執行順序 select 4 字段列表 from 1 表名列表 where 2 條件列表 group by 3 分組前過濾 having 分組后過濾 order by 5 排序字段列表 limit 6 分頁參數 聚合函數 count 統計數量 max 最大值 min 最小值 avg 平均 sum 總和 分組查詢使…

《程序人生》工作2年感悟

一些雜七雜八的感悟&#xff1a; 1.把事做好比什么都重要&#xff0c; 先樹立量良好的形象&#xff0c;再橫向發展。 2.職場就是人情世故&#xff0c;但也不要被人情世故綁架。 3.要常懷感恩的心&#xff0c;要記住幫助過你的人&#xff0c;愿意和你分享的人&#xff0c;有能力…

17.2 圖形繪制8

版權聲明&#xff1a;本文為博主原創文章&#xff0c;轉載請在顯著位置標明本文出處以及作者網名&#xff0c;未經作者允許不得用于商業目的。 17.2.10 重繪 先看以下例子&#xff1a; 【例 17.28】【項目&#xff1a;code17-028】繪制填充矩形。 private void button1_Clic…

自定義數據集 使用pytorch框架實現邏輯回歸并保存模型,然后保存模型后再加載模型進行預測,對預測結果計算精確度和召回率及F1分數

import numpy as np import torch import torch.nn as nn import torch.optim as optim from sklearn.metrics import precision_score, recall_score, f1_score# 數據準備 class1_points np.array([[1.9, 1.2],[1.5, 2.1],[1.9, 0.5],[1.5, 0.9],[0.9, 1.2],[1.1, 1.7],[1.4,…

neo4j入門

文章目錄 neo4j版本說明部署安裝Mac部署docker部署 neo4j web工具使用數據結構圖數據庫VS關系數據庫 neo4j neo4j官網Neo4j是用ava實現的開源NoSQL圖數據庫。Neo4作為圖數據庫中的代表產品&#xff0c;已經在眾多的行業項目中進行了應用&#xff0c;如&#xff1a;網絡管理&am…

腳本運行禁止:npm 無法加載文件,因為在此系統上禁止運行腳本

問題與處理策略 1、問題描述 npm install -D tailwindcss執行上述指令&#xff0c;報如下錯誤 npm : 無法加載文件 D:\nodejs\npm.ps1&#xff0c;因為在此系統上禁止運行腳本。 有關詳細信息&#xff0c;請參閱 https:/go.microsoft.com/fwlink/?LinkID135170 中的 about_…

Java基礎——分層解耦——IOC和DI入門

目錄 三層架構 Controller Service Dao ?編輯 調用過程 面向接口編程 分層解耦 耦合 內聚 軟件設計原則 控制反轉 依賴注入 Bean對象 如何將類產生的對象交給IOC容器管理&#xff1f; 容器怎樣才能提供依賴的bean對象呢&#xff1f; 三層架構 Controller 控制…

智慧園區系統集成解決方案引領未來城市管理的智能化轉型

內容概要 在現代城市管理的背景下&#xff0c;“智慧園區系統集成解決方案”正扮演著越來越重要的角色。這種解決方案不僅僅是技術上的創新&#xff0c;更是一種全新的管理理念&#xff0c;它旨在通過高效的數據整合與分析&#xff0c;優化資源配置&#xff0c;提升運營效率。…

99.24 金融難點通俗解釋:MLF(中期借貸便利)vs LPR(貸款市場報價利率)

目錄 0. 承前1. 什么是MLF&#xff1f;1.1 專業解釋1.2 通俗解釋1.3 MLF的三個關鍵點&#xff1a; 2. 什么是LPR&#xff1f;2.1 專業解釋2.2 通俗解釋2.3 LPR的三個關鍵點&#xff1a; 3. MLF和LPR的關系4. 傳導機制4.1 第一步&#xff1a;央行調整MLF4.2 第二步&#xff1a;銀…

【VM】VirtualBox安裝CentOS8虛擬機

閱讀本文前&#xff0c;請先根據 VirtualBox軟件安裝教程 安裝VirtualBox虛擬機軟件。 1. 下載centos8系統iso鏡像 可以去兩個地方下載&#xff0c;推薦跟隨本文的操作用阿里云的鏡像 centos官網&#xff1a;https://www.centos.org/download/阿里云鏡像&#xff1a;http://…

Elasticsearch中的度量聚合:深度解析與實戰應用

在大數據和實時分析日益重要的今天&#xff0c;Elasticsearch以其強大的搜索和聚合能力&#xff0c;成為了眾多企業和開發者進行數據分析和處理的首選工具。本文將深入探討Elasticsearch中的度量聚合&#xff08;Metric Aggregations&#xff09;&#xff0c;展示其如何在數據分…

C_C++輸入輸出(下)

C_C輸入輸出&#xff08;下&#xff09; 用兩次循環的問題&#xff1a; 1.一次循環決定打印幾行&#xff0c;一次循環決定打印幾項 cin是>> cout是<< 字典序是根據字符在字母表中的順序來比較和排列字符串的&#xff08;字典序的大小就是字符串的大小&#xff09;…

電腦要使用cuda需要進行什么配置

在電腦上使用CUDA&#xff08;NVIDIA的并行計算平臺和API&#xff09;&#xff0c;需要進行以下配置和準備&#xff1a; 1. 檢查NVIDIA顯卡支持 確保你的電腦擁有支持CUDA的NVIDIA顯卡。 可以在NVIDIA官方CUDA支持顯卡列表中查看顯卡型號是否支持CUDA。 2. 安裝NVIDIA顯卡驅動…

深入解析:一個簡單的浮動布局 HTML 示例

深入解析&#xff1a;一個簡單的浮動布局 HTML 示例 示例代碼解析代碼結構分析1. HTML 結構2. CSS 樣式 核心功能解析1. 浮動布局&#xff08;Float&#xff09;2. 清除浮動&#xff08;Clear&#xff09;3. 其他樣式 效果展示代碼優化與擴展總結 在網頁設計中&#xff0c;浮動…

家居EDI:Hom Furniture EDI需求分析

HOM Furniture 是一家成立于1977年的美國家具零售商&#xff0c;總部位于明尼蘇達州。公司致力于提供高品質、時尚的家具和家居用品&#xff0c;滿足各種家庭和辦公需求。HOM Furniture 以廣泛的產品線和優質的客戶服務在市場上贏得了良好的口碑。公司經營的產品包括臥室、客廳…

【VUE案例練習】前端vue2+element-ui,后端nodo+express實現‘‘文件上傳/刪除‘‘功能

近期在做跟畢業設計相關的數據后臺管理系統&#xff0c;其中的列表項展示有圖片展示&#xff0c;添加/編輯功能有文件上傳。 “文件上傳/刪除”也是我們平時開發會遇到的一個功能&#xff0c;這里分享個人的實現過程&#xff0c;與大家交流談論~ 一、準備工作 本次案例使用的…

C++中的析構器(Destructor)(也稱為析構函數)

在C中&#xff0c;析構器&#xff08;Destructor&#xff09;也稱為析構函數&#xff0c;它是一種特殊的成員函數&#xff0c;用于在對象銷毀時進行資源清理工作。以下是關于C析構器的詳細介紹&#xff1a; 析構函數的特點 名稱與類名相同&#xff0c;但前面有一個波浪號 ~&a…