vue中自定义设置多语言,并且运行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/pingmian/39730.shtml

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

相关文章

红酒与舞蹈:舞动的味觉艺术

在艺术的海洋中&#xff0c;红酒与舞蹈总是能激起人们心中较温柔的涟漪。红酒以其深邃的色泽、馥郁的香气&#xff0c;诠释着味觉的艺术&#xff1b;而舞蹈&#xff0c;则以优雅的姿态、灵动的步伐&#xff0c;演绎着视觉的盛宴。当红酒遇上舞蹈&#xff0c;一场别开生面的艺术…

少见的更优写法,反转字符串中的元音字母

Leetcode 原题链接 解法一 这道题很简单&#xff0c;令双指针 l l l 和 r r r 从两侧相向移动&#xff0c;交换元音字母即可。但大多人的实现是如下这种可简化的嵌套循环。 如果是 Java 等 String 不可变的语言&#xff0c;应先转换为 CharArray&#xff0c;交换完元音字母…

家用洗地机什么牌子好?四款公认品牌好的机型推荐

每个人都希望自己的家里面能够干干净净&#xff0c;就算不是一尘不染&#xff0c;也至少应该是整洁的&#xff0c;但是在这个快节奏的大环境下&#xff0c;做清洁对于人们来说&#xff0c;不是没时间&#xff0c;就是太累了。正当此时&#xff0c;一款造福懒人的神器——家用洗…

4D 生物打印技术的挑战:从打印到植入,还有多远?

4D生物打印技术将时间维度融入生物打印&#xff0c;为构建具有动态特性和功能的生物组织结构提供了无限可能。然而&#xff0c;要实现这些目标&#xff0c;选择合适的生物打印技术至关重要。本文将详细介绍几种主要的4D生物打印技术&#xff0c;并分析它们各自的优缺点&#xf…

前端初学java二(类、多态、接口、内部类、泛型)

目录 类 种类 Javabean类 测试类 工具类 类的初始化 构照函数 新建对象的内存图 static 继承 This Super 虚方法表 Override 修饰符权限 构造代码块 静态代码块 多态 前提 优点 缺点 示例 抽象方法 抽象类 接口 implements 继承 内部类 成员内部类…

React+TS 从零开始教程(4):useEffect

上一节传送门&#xff1a;ReactTS 从零开始教程&#xff08;3&#xff09;&#xff1a;useState 源码链接&#xff1a;https://pan.quark.cn/s/c6fbc31dcb02 上一节&#xff0c;我们已经学会了React的第一个Hook&#xff1a;useState。 这一节&#xff0c;我们要学习的是另一…

C语言----文件操作

1.为什么使用文件&#xff1f; 如果没有⽂件&#xff0c;我们写的程序的数据是存储在电脑的内存中&#xff0c;如果程序退出&#xff0c;内存回收&#xff0c;数据就丢失了&#xff0c;等再次运⾏程序&#xff0c;是看不到上次程序的数据的&#xff0c;如果要将数据进⾏持久化…

Java语言开发的一套智慧产科系统源码:产科专科电子病历系统源码

Java语言开发的一套智慧产科系统源码&#xff1a;产科专科电子病历系统源码 系统概述 电子病历系统是以住院病人为中心&#xff0c;面向医生以及护士为主的&#xff0c;涉及临床治疗、护理等业务的临床信息系统&#xff0c;以电子信息技术为手段&#xff0c;实时采集病人在整个…

【每日一练】Python遍历循环

1. 情节描述&#xff1a;上公交车(10个座位)&#xff0c;并且有座位就可以坐下 要求&#xff1a;输入公交卡当前的余额&#xff0c;只要超过2元&#xff0c;就可以上公交车&#xff1b;如果车上有空座位&#xff0c;才可以上。 seat 10 while seat > 0:money int(input(…

分层解耦----

分层解耦 类聚 软件中各个功能模块内部的功能联系. 例如: 高类聚示例&#xff1a;想象一下餐厅的厨房&#xff0c;每个厨师负责自己的工作站&#xff0c;一个专门做沙拉&#xff0c;一个专门烤肉&#xff0c;另一个专门做甜点。每个工作站内的工作高度类聚&#xff0c;即每个…

vite项目如何在本地启动https协议

vite项目如何在本地启动https协议 本地启动正常配置在vite.config.js文件中默认启动http协议的请求&#xff0c;如何改成https呢&#xff1f;今天的开发中遇到了这个问题项目需求&#xff1a; 本地启动https协议的前端页面并且正常访问后台https协议的接口 解决方法&#xff1a…

Elasticsearch:Runtime fields - 运行时字段(二)

这是继上一篇文章 “Elasticsearch&#xff1a;Runtime fields - 运行时字段&#xff08;一&#xff09;” 的续篇。 在查询时覆盖字段值 如果你创建的运行时字段与映射中已存在的字段同名&#xff0c;则运行时字段会隐藏映射字段。在查询时&#xff0c;Elasticsearch 会评估运…

MySQL 8.0新特性INTERSECT和EXCEPT用于集合运算

MySQL8.0.31 新版本的推出&#xff0c;MySQL增加了对SQL标准INTERSECT和EXCEPT运算符的支持。 1、INTERSECT INTERSECT输出多个SELECT语句查询结果中的共有行。INTERSECT运算符是ANSI/ISO SQL标准的一部分(ISO/IEC 9075-2:2016(E))。 我们运行两个查询&#xff0c;第一个会列…

Python基础小知识问答系列-获取列表中最大或最小N个元素

1. 问题: 怎么从数值列表中获取最大或最小几个元素&#xff1f; 怎么从字典元素列表中&#xff0c;获取字典中某个值最大或最小的几个字典元素&#xff1f; 2. 解决方法&#xff1a; 使用heapq模块中的nlargest、nsmallest。 示例&#xff1a; import heapqtest_list [1, 3…

java基于ssm+vue 病人跟踪治疗信息管理系统

1病人功能模块 病人登录进入病人跟踪治疗信息管理系统可以查看首页、个人中心、病例采集管理、预约管理、医生管理、上传核酸检测报告管理、上传行动轨迹管理、病人治疗状况管理等内容。 病例采集管理&#xff0c;在病例采集管理页面可以查看账号、姓名、住院号、入院时间、病…

电通出席2024年世界经济论坛(WEF),重申推动可持续发展创新和人才培育的承诺

中国&#xff0c;上海——电通将出席世界经济论坛2024年新领军者年会&#xff08;夏季达沃斯&#xff09;&#xff0c;本次大会将于6月25日至6月27日在中国大连举行。 2024年世界经济论坛主题为“未来增长的新前沿”&#xff0c;将聚焦于全球经济复苏、通胀缓解&#xff0c;以…

前端基础:JavaaScript(篇二)

目录 内置对象 String字符串 属性 代码 运行 方法 代码 运行 日期 代码 运行 Math 代码 运行 数组 定义 属性 代码 运行 方法 join(分隔符>) &#xff1a; 代码 运行 reverse()&#xff1a; 代码 运行 sort() &#xff1a; 代码 运行 事件 …

Elasticsearch实战教程: 如何在海量级数据中进行快速搜索

&#x1f3ac; 鸽芷咕&#xff1a;个人主页 &#x1f525; 个人专栏: 《C干货基地》《粉丝福利》 ⛺️生活的理想&#xff0c;就是为了理想的生活! 引入 Elasticsearch&#xff08;简称ES&#xff09;是一个基于Apache Lucene™的开源搜索引擎&#xff0c;无论在开源还是专有领…

【SPIE独立出版】第四届智能交通系统与智慧城市国际学术会议(ITSSC 2024)

第四届智能交通系统与智慧城市国际学术会议&#xff08;ITSSC 2024&#xff09;将于2024年8月23-25日在中国西安举行。本次会议主要围绕智能交通、交通新能源、无人驾驶、智慧城市、智能家居、智能生活等研究领域展开讨论&#xff0c; 旨在为该研究领域的专家学者们提供一个分享…

SWOT视角洞察:一篇文章详解AI Agent发展

AI Agent自盖茨远见后火爆&#xff0c;吴恩达提出设计模式成创业圣经。其优势显著&#xff1a;技术门槛低&#xff0c;市场需求广&#xff0c;非技术人员可参与开发。然而&#xff0c;挑战亦不容忽视&#xff1a;技术成熟度需提升&#xff0c;数据安全和隐私保护待加强&#xf…