我尝试使用nuxt-property-decorator在 nuxtjs 中添加元标签,但只添加了标题标签,但没有添加其他元标签
而且我也使用了 vue-meta包,但我也未能解决这个问题
这就是我的代码的样子:
<script lang="ts"> import { Component, Vue, Prop } from "nuxt-property-decorator"; @Component({ metaInfo:{ title: 'Default Title', titleTemplate: '%s | vue-meta Example App', meta: [ { charset: 'utf-8' }, { vmid: 'description', name: 'description', content: 'this is a description'} ] }, components: { } }) export default class HomePage extends Vue { }
从上面的代码只添加标题标签
- 尝试使用 Nuxtjs文档代码:
<script lang="ts">
import { Component, Vue, Prop } from "nuxt-property-decorator";
@Component({
head: {
title: 'my website title',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: 'my website description'
}
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
},
components: {
}
})
export default class HomePage extends Vue {
}
</script>
它没有添加任何东西
- 即使以这种方式尝试,这也不起作用
@Component({
head: {
title: 'my website title',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: 'my website description'
}
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
}
- 其他方式在类中添加代码。没用。
export default class PwHomePage extends Vue {
head() {
return {
title: "Default Title",
meta: [
{
hid: 'description',
name: 'description',
content: 'Home page description'
}
]
}
}
- 另一种方式。
export default class PwHomePage extends Vue {
metaInfo() {
return {
title: 'Default Title',
titleTemplate: '%s | vue-meta Example App',
meta: [{
vmid: 'description',
name: 'description',
content: "this.description",
}]
}
}
}