Reputation: 350
ocaasionaly this error came when i wrote code for input tags for keyup and keypress event and their corresponding vue code it was working but when i wrote
next input tag for keydown event and their correspoding vue code i got an error
like
till two input i have run this code earlier so i removed my new code and their corresponding vue code and than i again run but now i am still getting error in my correct previous code also
//leckeyboadevent.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
</head>
<body>
<div id="myapp">
<input type="text" placeholder="keypress" @keypress="keypressfun" >
<br\>
<input type="text" placeholder="keyup" @keyup="keyupfun">
<br\>
<input type="text" placeholder="keydown" @keydown="keydownfun">
</div>
<script src="lec6keyboardevent.js"></script>
</body>
</html>
//this my js file
var myapp=new Vue({
el:"#myapp",
data:{
},
methods:{
keypressfun:function(event){
console.log(event.key);
},
keyupfun:function(event)//this works when key release
{
console.log(event);
},
keydownfun:function()
{
console.log("keydown");
}
}
});
i am getting error
vue.js:634 [Vue warn]: Failed to generate render function:
SyntaxError: Unexpected string in
with(this){return _c('div',{attrs:{"id":"myapp"}},[_c('input',{attrs:{"type":"text","placeholder":"keypress"},on:{"keypress":keypressfun}}),_v(" "),_c('br',{attrs:{"\":""}}),_v(" "),_c('input',{attrs:{"type":"text","placeholder":"keyup"},on:{"keyup":keyupfun}}),_v(" "),_c('br',{attrs:{"\":""}}),_v(" "),_c('input',{attrs:{"type":"text","placeholder":"keydown"},on:{"keydown":keydownfun}}),_v(" "),_c('br'),_c('br')])}
(found in <Root>)
Upvotes: 1
Views: 526
Reputation: 166
Hi @user9083922 I think the problem is how you are closing your html tags.
Have you tried to close the br tags this standard way <br/>
instead of <br\>
?
It should work with this change.
In addition, if you want, <br>
tags doesn't need to be closed in html5 as they are void elements.
For more info you can check: https://www.w3.org/TR/html/syntax.html#writing-html-documents-elements
Upvotes: 1