2 回答

TA貢獻1780條經驗 獲得超4個贊
你可以做這樣的事情。
var meta = [{
name: "description", content: this.Post.Title
},
{
name: "date", content: this.Post.DateCreated
},
{
name: "author", content: this.Post.Author
}]
this.Tags.forEach(function (TagName, index) {
meta.push({ property: "tag", content: "TagName" })
})
metaInfo() {
return {
htmlAttrs: { lang: "en"
},
title: this.Post.Title,
// or you can just write "meta" instead of "meta: meta" its an shorthand // code
meta: meta
}
}

TA貢獻1770條經驗 獲得超3個贊
除非我遺漏了什么,否則您可以使用 push 并傳遞對象。
var meta = [];
meta.push({"property" : "tag","content" : "test"});
console.log(meta);
添加回答
舉報