修改head信息
head: {
title: '我是标题啊',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'keywords', name: 'keywords', content: '哈哈,嘿嘿,乎乎' },
{ hid: 'description', name: 'description', content: '啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
script: [
//head添加js
{ src: 'https://s9.greatytc.com/z_stat.php?id=123456789&web_id=321456987' }
]
},
修改页面title
async asyncData({ $axios,params,app }) {
app.head.title = '体语文章资讯-'
// console.log(articleConten)
return {}
},
配置axios代理
modules: ['@nuxtjs/axios'],
axios: {
prefix: '/api/',
proxy: true
},
proxy: {
'/api/': {
target: 'https://sys.new-obj.com/',
pathRewrite: {
'^/api/': ''
}
}
},
页面加入第三方js
default.vue
import {seo} from '~/static/js/assist'
export default {
mounted(){
seo();
}
}
assist.js
export function seo() {
let script = document.createElement('script')
script.src = 'https://s9.greatytc.com/z_stat.php?id=123456789&web_id=321456987'
script.language = 'javascript'
document.body.appendChild(script)
document.dispatchEvent(new Event('render-event'))
}