const dateformat = import('dateformat')
template.defaults.imports.dateformat = dateformat;
const html = template('xx.art',{
time:new Date()
})
报错
错误信息:RuntimeError: dateFormat is not a function]
解决:
不使用dateformat,用moment代替
在powershell里面下载 npm install moment
const moment = require('moment')
template.defaults.imports.moment = moment;
模板文件(xx.art)
{{ moment(time).format("YYYY-MM-DD HH:mm:ss") }}