我试图在服务器端使用Riotjs
我有三个文件testcmp.js
,test1.tag
,test2.tag
testcmp.js
var riot = require('riot');
var test1 = require('../src/components/test/test1.tag')
var test2 = require('../src/components/test/test2.tag')
console.log(riot.render('test2',{yo2:"hello"}))
test1.tag
<test1><div>I'm in test1 {opts.yo}</div></test1>
test2.tag
<test2>
<test1 yo="sujeet"></test1>
hello, I'm in test2 {yo2}
</test2>
当我运行testcmp.js文件时,收到以下错误消息
/home/sujeet/Desktop/labz/authblue-ui-ssr-spike/src/components/test/test2.tag:2
var riot = require('riot')
^^^^^^^^^^^^^^^
ReferenceError: Invalid left-hand side in assignment
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at loadAndCompile (/home/sujeet/Desktop/labz/authblue-ui-ssr-spike/node_modules/riot/lib/server/index.js:33:11)
at Object.require.extensions..tag (/home/sujeet/Desktop/labz/authblue-ui-ssr-spike/node_modules/riot/lib/server/index.js:55:3)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
npm ERR! Linux 4.13.0-32-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "testcmp"
npm ERR! node v6.11.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! authblue-ui-ssr-spike@1.0.0 testcmp: `node scripts/testcmp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the authblue-ui-ssr-spike@1.0.0 testcmp script 'node scripts/testcmp'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the authblue-ui-ssr-spike package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node scripts/testcmp
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs authblue-ui-ssr-spike
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls authblue-ui-ssr-spike
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/sujeet/Desktop/labz/authblue-ui-ssr-spike/npm-debug.log
答案 0 :(得分:0)
将文本包含在test2.tag文件中帮助我解决了这个问题。
基本上,就像这样
<test2>
<test1 yo="sujeet"></test1>
<span>hello, I'm in test2 {yo2} </span>
</test2>