vue-meta-info 原先的vue3 下可以用
但是在新版本下就无法使用了
<script setup>
const metaInfo= ()=> {
return {
//metaInfo:{
title: 'title',
meta: [
{ vmid: 'keywords',name: 'keywords', content: 'keywords' },
{ vmid: 'description',name: 'description', content: 'description' }
]
}
//}
}
请问最新版有新的seo meta 设置插件吗
var VueMetaInfo = function () {
};
VueMetaInfo.install = function (Vue) {
Vue.mixin({
beforeCreate: function beforeCreate() {
var this$1 = this;
// 如果组件内设置了 vueMeta 信息
if (this.$options[VUE_META_KEY_NAME] !== undefined) {
var type = typeof this.$options[VUE_META_KEY_NAME];
// 区分是否存在 vueMeta 信息
this._hasMetaInfo = true;
// 判断组件内是否存在 computed 对象
if (typeof this.$options.computed === 'undefined') {
this.$options.computed = {};
}
// 为组件添加 computed 对象并返回 vueMeta 信息
this.$options.computed.$metaInfo = type === 'function' ? this.$options[VUE_META_KEY_NAME] :
function () { return this$1.$options[VUE_META_KEY_NAME]; };
}
},
created: function created () {
renderServerMetaInfo(this.$ssrContext, this.$metaInfo);
},
beforeMount: function beforeMount() {
// 在组件挂载到 dom 之前更新 meta 信息
if (this._hasMetaInfo) {
updateMetaInfo(this.$metaInfo);
}
},
mounted: function mounted() {
var this$1 = this;
// dom 挂载之后 继续监听 meta 信息。如果发生变化,继续更新
if (this._hasMetaInfo) {
this.$watch('$metaInfo', function () {
updateMetaInfo(this$1.$metaInfo);
});
}
},
activated: function activated() {
if (this._hasMetaInfo) {
// keep-alive 组件激活时调用
updateMetaInfo(this.$metaInfo);
}
},
deactivated: function deactivated() {
if (this._hasMetaInfo) {
// keep-alive 组件停用时调用。
updateMetaInfo(this.$metaInfo);
}
}
});
};
vue 3.2 已经没有了 beforeCreate 方法