我有这个 Vue 应用程序,它由一个简单的主页、一个标题和一个主页文本组成。你可以在我的JSFiddle上在线查看这个应用程序。这是代码:
HTML
<div id="app">
My header app
<router-view></router-view>
</div>
JavaScript
const Home = {
template: `
<div>
<h1>{{ $t('home.title') }}</h1>
<p v-html="$t('home.text')"></p>
</div>
`
};
const messages = {
en: {
home: {
title: 'Hello world',
text: 'Find all post by clicking <router-link to="/post">this link</router-link>!'
}
}
};
const routes = [
{ name: 'home', path: '*', component: Home }
];
const i18n = new VueI18n({
locale: 'en',
fallbackLocale: 'en',
messages: messages
});
const router = new VueRouter({
mode: 'history',
routes: routes
});
const vue = new Vue({
el: '#app',
router: router,
i18n: i18n
});
问题
如您所见,没有可见的“路由器链接”链接,单击该链接不会重定向到所需的路由。
问题
是否可以让 VueI18n<router-link>
在指令中解释标签v-html
?