vue中自定义设置多语言(包括使用vue-i18n),并且运行js脚本自动生成多语言文件

在项目中需要进行多个国家语言的切换时,可以用到下面方法其中一个

一、自定义设置多语言

方法一:

可以自己编写一个设置多语言文件

在项目新建js文件,命名为:language.js,代码如下

// language.js 文档
let languagePage = {CN: {frame_rules: "规则",frame_remark: "虚位拟待",},EN: {frame_rules: "Rules",frame_remark: "Vacant position",},IN: {frame_rules: "Aturan",frame_remark: "Posisi Kosong",},VI: {frame_rules: "Quy tắc",frame_remark: "Vị trí Trống",},MS: {frame_rules: "Peraturan",frame_remark: "Jawatan Kosong",},TH: {frame_rules: "กฎ",frame_remark: "ตำแหน่งว่าง",},HI: {frame_rules: "กฎ",frame_remark: "खाली पद",},
};
export const getLangue = () => {// 获取我们设置存放在浏览器的localStorage 的语言类型let { language } =JSON.parse(window.localStorage.getItem("userInfo")) || {};// if (language == "ar") {//   // 阿拉伯语 展示顺序会相反,设置反向,使语言展示正常//   document.documentElement.setAttribute("dir", "rtl");//   // document.getElementById("app") &&//   //   document.getElementById("app").classList.add("ar");// }// zh  中文// en 英文// in  印尼// vi  越南// ms 马拉西亚// th  泰语// hi  印度语// ar 阿拉伯语let list = {in: "IN",id: "IN",zh: "CN",ms: "MS",vi: "VI",th: "TH",hi: "HI",};//假设能读取到浏览器设置的语言,就使用该语言 ,假设没有设置到浏览器任何语言类型,就默认使用英文if (list[language]) return languagePage[list[language]];return languagePage.EN;
};

在组件中使用多语言:

<template><div><!-- 使用多语言 --><div>{{ language.frame_rules }}</div></div>
</template>
<script>
// 在需要的组件引入多语言文件
import { getLangue } from "@/utils/language.js";export default {data() {return {language: getLangue(), //赋值多语言};},mounted() {},computed: {},methods: {},
};
</script>
<style lang="scss" scoped></style>

设置类型语言 :

你可以在app.vue的生命周期设置

//vue的生命周期mounted设置语言为中文
mounted() {const langType = JSON.stringify({ language: "zh" });window.localStorage.setItem("userInfo", langType);
},

当然,你可以写选择器,让用户选择对应的语言,然后强制刷新浏览器后便生效了

 const langType = JSON.stringify({ language: "zh" });window.localStorage.setItem("userInfo", langType);window.location.reload(); //设置完语言后 强制刷新浏览器才生效

方法二:使用使用vue-i18n 库,提示,下面展示是vue3中使用为例子

官方文档介绍:介绍 | Vue I18n

使用npm导入vue-i18n

npm i vue-i18n@next  --save

1、创建i18n所需文件夹(这里最好放置src下)

在src下建文件夹lang,在文件夹下新建文档 en.ts 和zh.ts 文档里面内容如下

en.ts文档:

// en.js文档//键值命名一定要和zh.ts 一一对应 ,键值的写法可用双引号,例如:"OP_check",也可不用。例如:home// 英文
const en = {"OP_check": "CHECK",home: "Home",
};
export default en;

zh.ts文档:

// zh.js文档// 中文
const zh = {"OP_check": "查看",home: "主页",
};
export default zh;

2.在文件夹lang新建文档 命名 index.ts

index.ts文档:

import en from "./en"; // 英文
import zh from "./zh"; // 中文//导出所有翻译内容
export default {en,zh,
};

3、在文件夹lang新建文档 命名 i18n.ts

i18n.ts文档

import { createApp } from "vue";
//这里注意引入的App.vue文件路径,确保文件成功被引进来
import App from "../App.vue";import { createI18n } from "vue-i18n";
import messages from "./index";const app = createApp(App);
const language = (navigator.language || "en").toLocaleLowerCase(); // 这是获取浏览器的语言if (!localStorage.getItem("lang")) {localStorage.setItem("lang", "en"); //设置默认语言为英文
}const i18n = createI18n({legacy: false, //处理报错Uncaught (in promise) SyntaxError: Not available in legacy mode (at message-compiler.esm-bundler.js:54:19)locale: localStorage.getItem("lang") || language.split("-")[0] || "en", //注意locale属性! 首先从缓存里拿,没有的话就用浏览器语言,fallbackLocale: "en", // 设置备用语言messages,
});export default function (app: any) {app.use(i18n);
}

4、在vue的mian文件,全局注入多语言

主要代码如下;

import i18n from "@/lang/i18n"; //导入多语言app.use(i18n); //全局注入多语言

5、在项目中使用多语言

在dom元素上直接使用vue-i18n如下

<template><!-- 在 dom中使用vue-i18n--><div>{{ $t("home") }}</div>
</template>

在<script>脚本中使用vue-i18n如下

<template><!-- 在 dom中使用vue-i18n--><div>{{ $t("home") }}</div>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { useI18n } from "vue-i18n"; //引入vue-i18n
const { t } = useI18n(); // 使用多语言关键字 t ——> vue-i18内置关键字,不可改写名字
const title = ref(t("OP_check"));  //在js代码中使用vue-i18n 这里的title === "CHECK"
</script>
<style scoped lang="scss"></style>

6、使用vue-i18n设置语言

<template><!-- 在 dom中使用vue-i18n--><div>{{ $t("home") }}</div>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { useI18n } from "vue-i18n"; //引入vue-i18n
const { locale } = useI18n(); // 使用多语言关键字 locale ——> vue-i18内置关键字,不可改写名字
const changLanguage = (e: any) => {
// 设置语言,其中locale是vue-i18内置设置语言的固定方法;改变locale的值就是改变语言类型了if (Number(e) === 1) {locale.value = "en";localStorage.setItem("lang", "en");} else {locale.value = "zh";localStorage.setItem("lang", "zh");}window.location.reload(); // 设置语言完成后,强制刷新浏览器,效果更换好
};
</script>
<style scoped lang="scss"></style>

上面设置多语言需要一个个复制粘贴进去,在开发工作的过程中很麻烦,是非常浪费时间的无脑操作,下面我们通过脚本,自动生成多语言文档,

二、运行js脚本自动生成多语言文件

1、在src同级目录下,新建目录命名 tools 

2.在tools 下新建文件夹 命名lang

3、在lang文件夹下,新建文档 命名:package-lock.json

package-lock.json文档代码如下

{"name": "app","version": "1.0.0","lockfileVersion": 1,"requires": true,"dependencies": {"@babel/runtime": {"version": "7.24.7","resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.7.tgz","integrity": "sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==","requires": {"regenerator-runtime": "^0.14.0"}},"adler-32": {"version": "1.2.0","resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.2.0.tgz","integrity": "sha512-/vUqU/UY4MVeFsg+SsK6c+/05RZXIHZMGJA+PX5JyWI0ZRcBpupnRuPLU/NXXoFwMYCPCoxIfElM2eS+DUXCqQ==","requires": {"exit-on-epipe": "~1.0.1","printj": "~1.1.0"}},"babel-plugin-transform-remove-console": {"version": "6.9.4","resolved": "https://registry.npmjs.org/babel-plugin-transform-remove-console/-/babel-plugin-transform-remove-console-6.9.4.tgz","integrity": "sha512-88blrUrMX3SPiGkT1GnvVY8E/7A+k6oj3MNvUtTIxJflFzXTw1bHkuJ/y039ouhFMp2prRn5cQGzokViYi1dsg==","dev": true},"buffer-from": {"version": "1.1.2","resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz","integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="},"cfb": {"version": "1.2.2","resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz","integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==","requires": {"adler-32": "~1.3.0","crc-32": "~1.2.0"},"dependencies": {"adler-32": {"version": "1.3.1","resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz","integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A=="}}},"codepage": {"version": "1.15.0","resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz","integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA=="},"crc-32": {"version": "1.2.2","resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz","integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ=="},"exit-on-epipe": {"version": "1.0.1","resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz","integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw=="},"frac": {"version": "1.1.2","resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz","integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA=="},"minimist": {"version": "1.2.8","resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz","integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="},"node-xlsx": {"version": "0.17.2","resolved": "https://registry.npmjs.org/node-xlsx/-/node-xlsx-0.17.2.tgz","integrity": "sha512-j92dGS8KvGPi6YpYovHrR9zWiyDONx7DiGhl1SjM+vzxAh3do6hmerFCyN+hRuK7QhwHdwzfpYxZm+hKA/uErA==","requires": {"@babel/runtime": "^7.15.4","buffer-from": "^1.1.2","xlsx": "^0.17.2"}},"printj": {"version": "1.1.2","resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz","integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ=="},"regenerator-runtime": {"version": "0.14.1","resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz","integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw=="},"ssf": {"version": "0.11.2","resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz","integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==","requires": {"frac": "~1.1.2"}},"wmf": {"version": "1.0.2","resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz","integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw=="},"word": {"version": "0.3.0","resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz","integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA=="},"xlsx": {"version": "0.17.5","resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.17.5.tgz","integrity": "sha512-lXNU0TuYsvElzvtI6O7WIVb9Zar1XYw7Xb3VAx2wn8N/n0whBYrCnHMxtFyIiUU1Wjf09WzmLALDfBO5PqTb1g==","requires": {"adler-32": "~1.2.0","cfb": "^1.1.4","codepage": "~1.15.0","crc-32": "~1.2.0","ssf": "~0.11.2","wmf": "~1.0.1","word": "~0.3.0"}}}
}

4、在lang文件夹下,新建文档 命名:package.json

package.json文档代码如下

{"name": "app","version": "1.0.0","lockfileVersion": 1,"requires": true,"dependencies": {"@babel/runtime": {"version": "7.24.7","resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.7.tgz","integrity": "sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==","requires": {"regenerator-runtime": "^0.14.0"}},"adler-32": {"version": "1.2.0","resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.2.0.tgz","integrity": "sha512-/vUqU/UY4MVeFsg+SsK6c+/05RZXIHZMGJA+PX5JyWI0ZRcBpupnRuPLU/NXXoFwMYCPCoxIfElM2eS+DUXCqQ==","requires": {"exit-on-epipe": "~1.0.1","printj": "~1.1.0"}},"babel-plugin-transform-remove-console": {"version": "6.9.4","resolved": "https://registry.npmjs.org/babel-plugin-transform-remove-console/-/babel-plugin-transform-remove-console-6.9.4.tgz","integrity": "sha512-88blrUrMX3SPiGkT1GnvVY8E/7A+k6oj3MNvUtTIxJflFzXTw1bHkuJ/y039ouhFMp2prRn5cQGzokViYi1dsg==","dev": true},"buffer-from": {"version": "1.1.2","resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz","integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="},"cfb": {"version": "1.2.2","resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz","integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==","requires": {"adler-32": "~1.3.0","crc-32": "~1.2.0"},"dependencies": {"adler-32": {"version": "1.3.1","resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz","integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A=="}}},"codepage": {"version": "1.15.0","resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz","integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA=="},"crc-32": {"version": "1.2.2","resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz","integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ=="},"exit-on-epipe": {"version": "1.0.1","resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz","integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw=="},"frac": {"version": "1.1.2","resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz","integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA=="},"minimist": {"version": "1.2.8","resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz","integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="},"node-xlsx": {"version": "0.17.2","resolved": "https://registry.npmjs.org/node-xlsx/-/node-xlsx-0.17.2.tgz","integrity": "sha512-j92dGS8KvGPi6YpYovHrR9zWiyDONx7DiGhl1SjM+vzxAh3do6hmerFCyN+hRuK7QhwHdwzfpYxZm+hKA/uErA==","requires": {"@babel/runtime": "^7.15.4","buffer-from": "^1.1.2","xlsx": "^0.17.2"}},"printj": {"version": "1.1.2","resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz","integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ=="},"regenerator-runtime": {"version": "0.14.1","resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz","integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw=="},"ssf": {"version": "0.11.2","resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz","integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==","requires": {"frac": "~1.1.2"}},"wmf": {"version": "1.0.2","resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz","integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw=="},"word": {"version": "0.3.0","resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz","integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA=="},"xlsx": {"version": "0.17.5","resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.17.5.tgz","integrity": "sha512-lXNU0TuYsvElzvtI6O7WIVb9Zar1XYw7Xb3VAx2wn8N/n0whBYrCnHMxtFyIiUU1Wjf09WzmLALDfBO5PqTb1g==","requires": {"adler-32": "~1.2.0","cfb": "^1.1.4","codepage": "~1.15.0","crc-32": "~1.2.0","ssf": "~0.11.2","wmf": "~1.0.1","word": "~0.3.0"}}}
}

5、在lang文件夹下,新建文档 命名:app.js

app.js文档代码如下

import { createRequire } from "module";const require = createRequire(import.meta.url);
var path = require("path");
var fs = require("fs");
var xlsx = require("node-xlsx").default;
const TABLE_KEY = "lang_key";
var _OutputPath = "../../src/lang/";function isExits(path) {try {fs.statSync(path);return true;} catch (e) {return false;}
}function loopSheet(data) {if (data) {let _myData = {};let _myIndex = {};//解析表头while (data.length > 0) {const _rData = data.shift();if (_rData.length > 0) {if (_rData[0] == TABLE_KEY) {let len = _rData.length > 4 ? 4 : _rData.length; // 这里数字表示要生产几个文件, 3表示生产两种多语言,假设4,便是生产3种多语言for (let index = 1; index < len; index++) {const element = _rData[index];_myData[element] = {};_myIndex[element] = index;}break;}}}console.log("====================================");console.log("语言结构:", _myIndex);console.log("语言结构:", _myData);console.log("====================================");let _keys1 = Object.keys(_myData);let _keys2 = Object.keys(_myIndex);//确保结构是对称的if (_keys1.length > 0 &&_keys2.length > 0 &&_keys1.length == _keys2.length) {//TODO:做数据的遍历、存储到需要的位置for (let row = 0; row < data.length; row++) {const _rData = data[row];for (const key in _myIndex) {if (_myIndex.hasOwnProperty(key)) {const _keyIndex = _myIndex[key];_myData[key][_rData[0]] = _rData[_keyIndex];}}}}console.log("====================================");console.log("数据汇总:", _myData);console.log("====================================");//写出文件for (const key in _myData) {if (_myData.hasOwnProperty(key)) {const _sheetData = _myData[key];let _file = _OutputPath + key + ".ts";let str ="const " +key +" = " +JSON.stringify(_sheetData, null, "\t") +";\n";str += "export default " + key + ";";fs.writeFile(_file, str, function (err) {if (err) {res.status(500).send("Server is error...");}});}}}
}function parse(path) {let _isFile = isExits(path);if (_isFile) {// var arr = path.split("/");// delete arr[arr.length - 1];// _OutputPath = arr.join("/");console.log("====================================");console.log("_OutputPath:", _OutputPath);console.log("====================================");const workSheetsFromFile = xlsx.parse(path);if (workSheetsFromFile) {for (let index = 0; index < workSheetsFromFile.length; index++) {const sheet = workSheetsFromFile[index];console.log("====================================");console.log(sheet.name);console.log("====================================");loopSheet(sheet.data);}} else {console.log("====================================");console.log("文件出错!");console.log("====================================");}} else {console.log("====================================");console.log("文件不存在!");console.log("====================================");}
}parse(process.argv[2]);

6、确认在src目录下有一个文件夹名字为lang 如下图

没有就必须创建文件夹名字为lang

7、使用xlsx表格导出多语言文档

xlsx表格也必须放在tools的lang目录下,xlsx表格名字可以随意命名,这里我命名为:TEXAS_i18n.xlsx

8、TEXAS_i18n.xlsx的书写格式如下,这个格式是不可更改的,需要严格对应

9.运行这个脚本需要安装node 确保电脑已经安装好node, 建议是14版本以上

10,运行脚本,生成多语言,需要在tools的lang目录运行

10.1先运行npm i

npm i

10.2.在运行

node .\app.js .\TEXAS_i18n.xlsx

如图:

11、查看运行结果,你会发现,在src的lang目录下,会生成三个文件

如果需要生成更多,请更改app,js文件个数,其他都不要改动就可

好了,编写完成,有需要请自行查看!!!!!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/42442.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

聊一下Maven打包的问题(jar要发布)

文章目录 一、问题和现象二、解决方法&#xff08;1&#xff09;方法一、maven-jar-pluginmaven-dependency-plugin&#xff08;2&#xff09;方法二、maven-assembly-plugin 一、问题和现象 现在的开发一直都是用spring boot&#xff0c;突然有一天&#xff0c;要自己开发一个…

Django之项目开发(二)

目录 一、安装和使用uWSGI 1.1、安装 1.2、配置文件 1.3、启动与停止uwsgi 二、安装nginx 三、Nginx 配置uWSGI 四、Nginx配置静态文件 五、Nginx配置负载均衡 一、安装和使用uWSGI uWSGI 是一个 Web 服务器,可以用来部署 Python Web 应用。它是一个高性能的通用的 We…

味蕾与理解:应对自闭症儿童挑食的策略与理解

在星贝育园自闭症康复学校&#xff0c;我们深知饮食习惯对孩子们的成长至关重要&#xff0c;而自闭症儿童的挑食问题往往比同龄儿童更为突出&#xff0c;给家长和照顾者带来了额外的挑战。今天&#xff0c;作为这里的老师&#xff0c;我想与大家分享一些应对自闭症儿童挑食的策…

(南京观海微电子)——电阻应用及选取

什么是电阻&#xff1f; 电阻是描述导体导电性能的物理量&#xff0c;用R表示。 电阻由导体两端的电压U与通过导体的电流I的比值来定义&#xff0c;即&#xff1a; 所以&#xff0c;当导体两端的电压一定时&#xff0c;电阻愈大&#xff0c;通过的电流就愈小&#xff1b;反之&…

鸿蒙应用实践:利用扣子API开发起床文案生成器

前言 扣子是一个新一代 AI 应用开发平台&#xff0c;无需编程基础即可快速搭建基于大模型的 Bot&#xff0c;并发布到各个渠道。平台优势包括无限拓展的能力集&#xff08;内置和自定义插件&#xff09;、丰富的数据源&#xff08;支持多种数据格式和上传方式&#xff09;、持…

[Unity入门01] Unity基本操作

参考的傅老师的教程学了一下Unity的基础操作&#xff1a; [傅老師/Unity教學] Unity3D基礎入門 [華梵大學] 遊戲引擎應用基礎(Unity版本) Class#01 移动&#xff1a;鼠标中键旋转&#xff1a;鼠标右键放大&#xff1a;鼠标滚轮飞行模式&#xff1a;右键WASDQEFocus模式&…

算法设计与分析 实验5 并查集法求图论桥问题

目录 一、实验目的 二、问题描述 三、实验要求 四、实验内容 &#xff08;一&#xff09;基准算法 &#xff08;二&#xff09;高效算法 五、实验结论 一、实验目的 1. 掌握图的连通性。 2. 掌握并查集的基本原理和应用。 二、问题描述 在图论中&#xff0c;一条边被称…

基于Android Studio订餐管理项目

目录 项目介绍 图片展示 运行环境 获取方式 项目介绍 能够实现登录&#xff0c;注册、首页、订餐、购物车&#xff0c;我的。 用户注册后&#xff0c;登陆客户端即可完成订餐、浏览菜谱等功能&#xff0c;点餐&#xff0c;加入购物车&#xff0c;结算&#xff0c;以及删减…

【学习笔记】操作系统--万字长文

计算机操作系统 文章目录 计算机操作系统引言 操作系统基本概念第一章 引论目标和作用操作系统发展历程单道批处理系统多道批处理系统分时系统实时系统 基本特征并发共享虚拟异步性&#xff08;不确定性&#xff09; 操作系统主要功能处理机管理内存管理设备管理文件管理 第二章…

工程化:Commitlint / 规范化Git提交消息格式

一、理解Commitlint Commitlint是一个用于规范化Git提交消息格式的工具。它基于Node.js&#xff0c;通过一系列的规则来检查Git提交信息的格式&#xff0c;确保它们遵循预定义的标准。 1.1、Commitlint的核心功能 代码规则检查&#xff1a;Commitlint基于代码规则进行检查&a…

汇聚荣拼多多电商的技巧有哪些?

在电商平台上&#xff0c;汇聚荣拼多多以其独特的商业模式和创新的营销策略吸引了大量消费者。那么&#xff0c;如何在这样一个竞争激烈的平台上脱颖而出&#xff0c;成为销售佼佼者呢?本文将深入探讨汇聚荣拼多多电商的成功技巧。 一、精准定位目标客户群体 首先&#xff0c;…

绝区肆--2024 年AI安全状况

前言 随着人工智能系统变得越来越强大和普及&#xff0c;与之相关的安全问题也越来越多。让我们来看看 2024 年人工智能安全的现状——评估威胁、分析漏洞、审查有前景的防御策略&#xff0c;并推测这一关键领域的未来可能如何。 主要的人工智能安全威胁 人工智能系统和应用程…

C-11 三角剖分的调研

C-11 三角剖分算法 三角剖分就是将输入的多边形&#xff0c;分割成一系列互不重叠的三角形&#xff0c;其重要性就在这不多赘述。这个是一个别人总结的链接&#xff1a;http://vterrain.org/Implementation/Libs/triangulate.html 图片链接&#xff1a;http://www-cgrl.cs.m…

基于CentOS Stream 9平台搭建MinIO以及开机自启

1. 官网 https://min.io/download?licenseagpl&platformlinux 1.1 下载二进制包 指定目录下载 cd /opt/coisini/ wget https://dl.min.io/server/minio/release/linux-amd64/minio1.2 文件赋权 chmod x /opt/coisini/minio1.3 创建Minio存储数据目录&#xff1a; mkdi…

springboot校园安全通事件报告小程序-计算机毕业设计源码02445

Springboot 校园安全通事件报告小程序系统 摘 要 随着中国经济的飞速增长&#xff0c;消费者的智能化水平不断提高&#xff0c;许多智能手机和相关的软件正在得到更多的关注和支持。其中&#xff0c;校园安全通事件报告小程序系统更是深得消费者的喜爱&#xff0c;它的出现极大…

《Programming from the Ground Up》阅读笔记:p19-p48

《Programming from the Ground Up》学习第2天&#xff0c;p19-p48总结&#xff0c;总计30页。 一、技术总结 1.object file p20, An object file is code that is in the machine’s language, but has not been completely put together。 之前在很多地方都看到object fi…

Git使用中遇到的问题(随时更新)

问题1.先创建本地库&#xff0c;后拉取远程仓库时上传失败的问题怎么解决&#xff1f; 操作主要步骤&#xff1a; step1 设置远程仓库地址: $ git remote add origin gitgitee.com:yourAccount/reponamexxx.git step2 推送到远程仓库: $ git push -u origin "master&qu…

线程池理解及7个参数

定义理解 线程池其实是一种池化的技术实现&#xff0c;池化技术的核心思想就是实现资源的复用&#xff0c;避免资源的重复创建和销毁带来的性能开销。线程池可以管理一堆线程&#xff0c;让线程执行完任务之后不进行销毁&#xff0c;而是继续去处理其它线程已经提交的任务。 …

GStreamer学习5----probe数据探测

参考资料&#xff1a; gstreamer中如何使用probe&#xff08;探针&#xff09;获取帧数据_gstreamer 视频编码时获取视频关键帧信息-CSDN博客 Gstreamer中可以使用AppSink作为一个分支来查看管线中的数据&#xff0c;还可以使用probe去处理。 在GStreamer中&#xff0c;probe…

LayerNorm Plugin的使用与说明

目录 前言0. 简述1. Layernorm Plugin的使用1.1 源码下载1.2 模型下载和修改1.3 环境配置1.4 编译1.4 engine生成和执行(trtexec)1.5 enging生成和执行(C API) 2. 补充说明2.1 RTMO显存占用问题2.2 插件找不到的说明2.3 LayerNorm plugin封装的尝试2.4 layerNorm plugin核函数实…