我是根據官方的栗子來學習的但是出現了一個問題我想用helper注冊一個方法但是總是提示template.helper is not a function不知是我調用時有問題還是引入的js有問題代碼如下<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>arttemplate</title> <script src="template-web.js"></script></head><body> <div id="content3"></div> <script id="test3" type="text/html"> //<p>{{add(1,2)}}</p> <p>{{add:'1,2'}}</p> </script></body><script> template.helper('add',function(val1,val2){ return val1 + val2; }); //var data3 = { //list: [32,45,47,61,52,41,32,29,44,24,55,19] //} var html = template('test3'); document.getElementById('content3').innerHTML = html;</script></html>
arttemplate.js的helper如何用?
BIG陽
2018-11-14 18:18:00