VUE3.0 学习之旅
程序员文章站
2024-01-02 12:33:28
...
VUE3.0 学习之旅
- 废除了filter,推荐统一使用methods
<template>
<!-- ✓ GOOD -->
{{ filter(msg) }}
{{ filter(msg, '€') }}
{{ filterB(filterA(msg)) }}
<div v-bind:id="filter(msg)"></div>
<div v-bind:id="filter(msg, '€')"></div>
<div v-bind:id="filterB(filterA(msg))"></div>
<!-- ✗ BAD -->
{{ msg | filter }}
{{ msg | filter('€') }}
{{ msg | filterA | filterB }}
<div v-bind:id="msg | filter"></div>
<div v-bind:id="msg | filter('€')"></div>
<div v-bind:id="msg | filterA | filterB"></div>
</template>
- plugins 全局使用
import { createApp } from 'vue'
import Root from './App.vue'
import i18nPlugin from './plugins/i18n'
const app = createApp(Root)
const i18nStrings = {
greetings: {
hi: 'Hallo!'
}
}
app.use(i18nPlugin, i18nStrings)
app.mount('#app')