我不得不将一个jade文件转换成pug格式。我设法纠正了一些错误,但我阻止了这一点:
> Error: C:\Users\Asus\Desktop\cours_nodejs\views\expressO1.pug:19:20
> 17| $.get('/hello/', + $('[name=name]:checked').val(),
> 18| function(data) {
> > 19| $('#message').html(data.message);
> ---------------------------^
> 20| }, 'json' );
> 21| }
>
> unexpected text "$('#m"
> at makeError (C:\Users\Asus\Desktop\cours_nodejs\node_modules\pug-error\index.js:32:13)
> at Lexer.error (C:\Users\Asus\Desktop\cours_nodejs\node_modules\pug-lexer\index.js:59:15)
> at Lexer.fail (C:\Users\Asus\Desktop\cours_nodejs\node_modules\pug-lexer\index.js:1441:10)
> at Lexer.advance (C:\Users\Asus\Desktop\cours_nodejs\node_modules\pug-lexer\index.js:1501:15)
> at Lexer.callLexerFunction (C:\Users\Asus\Desktop\cours_nodejs\node_modules\pug-lexer\index.js:1456:23)
> at Lexer.getTokens (C:\Users\Asus\Desktop\cours_nodejs\node_modules\pug-lexer\index.js:1512:12)
> at lex (C:\Users\Asus\Desktop\cours_nodejs\node_modules\pug-lexer\index.js:12:42)
> at Object.lex (C:\Users\Asus\Desktop\cours_nodejs\node_modules\pug\lib\index.js:99:27)
> at Function.loadString [as string] (C:\Users\Asus\Desktop\cours_nodejs\node_modules\pug-load\index.js:44:24)
> at compileBody (C:\Users\Asus\Desktop\cours_nodejs\node_modules\pug\lib\index.js:86:18)尽管我进行了研究,但我无法理解是什么导致了这个错误(也没有找到解决它的解决方案)。以下是pug文件的代码:
doctype html
head
title=theTitle
body
div Choisir unprenom :
- for name intheNames
label
input(type="radio", name="name", value=name)
spanPrenom : #{name}
br
div
input(type="button", onclick="valid()",value="OK")
#message
script(src="http://code.jquery.com/jquery-1.10.1.min.js")
script.
function.valid() {
$.get('/hello/', + $('[name=name]:checked').val(),
function(data) {
$('#message').html(data.message);
}, 'json' );
}谢谢你的建议!
https://stackoverflow.com/questions/51230496
复制相似问题