我创建了一个离子应用程序并添加了 vue-i18n。
npx ionic start myapp tabs --type vue
npm install vue-i18n@next
Run Code Online (Sandbox Code Playgroud)
我做了 VueI18n 设置的第一步,并将其添加到“./src/main.ts”:
import { createI18n } from 'vue-i18n';
const i18n = createI18n({
locale: 'de',
fallbackLocale: 'en',
messages: {en: {testMessage: 'Test message'}, de: {testMessage: 'Testnachricht'}}
});
Run Code Online (Sandbox Code Playgroud)
在npx ionic serve浏览器控制台中收到以下警告后查看结果时:
您正在运行 vue-i18n 的 esm-bundler 构建。建议将您的捆绑器配置为使用布尔文字显式替换功能标志全局变量,以便在最终捆绑包中进行适当的摇树。
我在浏览器控制台中得到了这个信息:
您正在运行 vue-i18n 的开发版本。确保在部署生产时使用生产版本 (*.prod.js)。
当我注释掉添加到“./src/main.ts”的代码段时,两个通知都消失了。所以它们似乎真的是由 vue-i18n 引起的。
问过谷歌后,我仍然不知道如何处理这些通知。他们在告诉我什么?我应该为他们做些什么吗?我可以具体做什么?
这些是在新项目的根文件夹中自动创建的文件:
./ionic.config.json
./cypress.json
./jest.config.js
./babel.config.js
./.gitignore
./package-lock.json
./package.json
./.eslintrc.js
./tsconfig.json
./capacitor.config.json
./.browserslistrc
Run Code Online (Sandbox Code Playgroud)
还请告诉我哪里需要更改。还
$ find . -type f ! -name package-lock.json …Run Code Online (Sandbox Code Playgroud) 在 Vue (v3) 中添加带有 a 的 propvalidator会导致 TypeScript 错误,声称另一个属性不存在。我创建了一个说明问题的组件:
这有效:
<template>
<div>{{myComputed}}</div>
</template>
<script lang="ts">
import { defineComponent, computed } from 'vue';
export default defineComponent({
name: 'MyComponent',
props: {
someProp: String
},
setup(props) {
return {
myComputed: computed(() => ('ABC_' + props.someProp + '_XYZ'))
};
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
现在我们添加otherProp一个validator:
<template>
<div>{{myComputed}}</div>
</template>
<script lang="ts">
import { defineComponent, computed } from 'vue';
export default defineComponent({
name: 'MyComponent',
props: {
someProp: String,
otherProp: {
type: String, …Run Code Online (Sandbox Code Playgroud)