如何在 metaInfo 中使用 Vue 变量?
How to use a Vue variable in metaInfo?
脚本中这一行 Vue 的正确语法是什么:
export default {
metaInfo: {
title: "{product.name} wallpaper",
一行来到表格:
title: "Space wallpaper",
product.name
我在 api:
mounted()
{
let vm = this
vm.getProducts();
},
methods: {
getProducts() {
let vm = this
axios.get('/api/products')
.then(function(response) {
vm.products = response.data.data
})
Template literals 在大括号前使用反引号和美元符号,例如:
title: `${product.name} wallpaper`
要在 metaInfo
中使用反应变量作为函数的一部分,Vue Meta docs 表示您可以使 metaInfo
成为一个函数并在之前将反应变量分配给局部变量返回数据。例如:
metaInfo() {
const product = this.product;
return {
title: `${product.name} wallpaper`
}
}
Vue Meta 的一位贡献者解释了为什么需要这样做 here。
脚本中这一行 Vue 的正确语法是什么:
export default {
metaInfo: {
title: "{product.name} wallpaper",
一行来到表格:
title: "Space wallpaper",
product.name
我在 api:
mounted()
{
let vm = this
vm.getProducts();
},
methods: {
getProducts() {
let vm = this
axios.get('/api/products')
.then(function(response) {
vm.products = response.data.data
})
Template literals 在大括号前使用反引号和美元符号,例如:
title: `${product.name} wallpaper`
要在 metaInfo
中使用反应变量作为函数的一部分,Vue Meta docs 表示您可以使 metaInfo
成为一个函数并在之前将反应变量分配给局部变量返回数据。例如:
metaInfo() {
const product = this.product;
return {
title: `${product.name} wallpaper`
}
}
Vue Meta 的一位贡献者解释了为什么需要这样做 here。