<script>
// import axios from 'axios'
var rapaxios = require('rap-axios-plugin')
export default {
data () {
return {
title: 'test',
staticD: { // 静态数据
wait: false,
fade: ''
},
dynamicD: { // 动态请求数据后覆盖此处的默认数据
'curpath': '/',
'gotopimg': '/img/i-top.png',
'logosrc': '/img/logo.png',
'nav': [
{ 'curpath': '/', 'txt': '首页' },
{ 'curpath': '/cases', 'txt': '案例' },
{ 'curpath': '/designers', 'txt': '设计师' },
{ 'curpath': '/properties', 'txt': '热装楼盘' },
{ 'curpath': '/constructions', 'txt': '在施工地' },
{ 'curpath': '/embodiments', 'txt': '别墅实施' },
{ 'curpath': '/furnishings', 'txt': '别墅软装' },
{ 'curpath': '/villas', 'txt': '出版刊物' },
{ 'curpath': '/about', 'txt': '关于' }
],
'rootdir': '/',
'tel': '400-001-5821',
'telimg': '/img/tel.png'
}
}
},
head () {
return {
title: this.title
meta: this.statsCode.meta
// link: [],
// script: this.statsCode
}
},
created () {
// console.log(this)
this.fetchData()
// this.pathfn() // 渲染dom前调用导航定位(异步在这写不起作用,写在fetchData方法里面)
},
methods: {
fetchData: function () {
console.log('开始请求数据......')
let that = this
// 配置projectId,使用前最好先配置config
rapaxios.config({
rootUrl: 'http://rap.taobao.org',
mock: 'mockjsdata',
projectId: '30077',
ismock: false
})
rapaxios
.get('api/default')
.then(function (res) {
that.dynamicD = res.data
console.log(res.data)
that.pathfn() // 渲染dom前调用导航定位
console.log('请求数据完成......')
})
.catch(function (err) {
console.log(err)
})
}
}
}
</script>
TypeError: Cannot read property 'meta' of undefined
at VueComponent.head (default.vue:77)