Vue3 配置 vue-meta-info(SEO优化)

安装

npm i vue-meta-info --save

main

import {
    
     createApp } from 'vue'
import App from './App.vue'
import router from '@/router'
import MetaInfo from 'vue-meta-info';

createApp(App).use(router).use(MetaInfo).mount('#app')

使用

<template>
    <div>
        首页
    </div>
</template>

<script>
    export default {
    
    
        name: 'index',
        components: {
    
    },
        metaInfo () {
    
    
            return {
    
    
                title: this.title,
                meta: [
                    {
    
    
                        charset: "utf-8"
                    },
                    {
    
    
                        name: 'keyWords',
                        content: '张童瑶,wall,测试'
                    },{
    
    
                        name: 'description',
                        content: '一个SEO优化的测试网站'
                    }
                ],
                link: [{
    
    
                    rel: 'asstes',
                    href: 'https://assets-cdn.github.com/'
                }]
            }
        },
        data(){
    
    
            return {
    
    
                title:"我是标题"
            }
        }
    }
</script>

<style scoped>

</style>

猜你喜欢

转载自blog.csdn.net/u014641168/article/details/129619948