Egg、ejs 使用include语法导入报错,有非法ejs标识符

在学习Egg.js时,尝试在HTML文件中使用EJS的`include`语句导入`header.html`时出现错误。原因为EJS期望的是`.ejs`文件。将`header.html`改为`header.ejs`后,问题得到解决,能够成功显示页面效果。
摘要由CSDN通过智能技术生成

egg学习中在一个.html文件中使用ejs语法

 <% include header.html %>

换成:

    <%- include ("header.html") %>

导入另一个.html文件时报错

Unexpected identifier in D:\egg\app\view\ejsTest.html while compiling ejs If the above error is not helpful, you may want to try EJS-Lint: https://github.com/RyanZim/EJS-Lint

 解决方案:

使用:<%- include("header.ejs") %>

例如:

    <%- include ("header.html") %>

就可以看到页面效果:

 

参考学习:node ejs简介 ejs语法总结 include()方法 - 爱码网

 EJS - 爱码网

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值