1.问题
使用vue-cli
的webpack
模版搭建的脚手架。想在footer.vue
文件中进行copyright的年份的设置,通过js获取当前年份,在computed部分进行copyright字符串的拼接(年份+网址)。vue-cli
脚手架的.vue
文件中只export了data,我尝试编写了computed
部分但是不起作用。
2.代码
<template>
<footer class="footer">
{{copyright}}
</footer>
</template>
<script>
export default {
data () {
return {
year: (new Date()).getFullYear(),
site: 'www.example.com',
}
},
computed() {
return {
copyright(){
return 'Copyright ©'+this.year+' '+this.site //not OK
}
}
}
}
</script>
<style>
</style>
3.错误信息&截图
呃其实没有截图的必要,就是版权信息没有输出。
4..vue
文件中,出了data外,methods和computed要怎样输出?