如何在 .vue 项目中显示当前年份

How to show current year in .vue project

我一直在做一个项目,我被困在这里。

我在 .vue 中使用 Jade 模板,我需要显示当前年份,但我无法做到

<template lang='jade'>
// Footer
footer#footer.footer
.container
  .row
.footer-wrapper
      .col-md-6.col-sm-6.col-xs-12
        .footer-brand
img(src='assets/images/logo-white.png', alt='logo')
      .col-md-6.col-sm-6.col-xs-12
.copyright
          p
 a(href='https://www.easycryptocoins.info/')  Easycryptos
            script.
© 2018 - {{ new Date().getFullYear() }}
| . All rights reserved.
  </template> 

          `

我希望获得 2018 年的版权 -(当年),但我只是开始使用 Easycryptos

尝试在您的数据对象中创建一个名为 'currentDate' 的 属性 并在您的模板中使用它,例如:

data(){
     return {
        currentDate: new Date,
        }
 }

在你的模板中这样做:

 {{currentDate.getFullYear()}}

您应该实例化对象以访问其方法。