简体   繁体   English

vue.js:465 [Vue 警告]:无法生成渲染函数:

[英]vue.js:465 [Vue warn]: Failed to generate render function:

I got an error like this:我收到这样的错误:

vue.js:465 [Vue warn]: Failed to generate render function:

ReferenceError: Invalid left-hand side in assignment in

with(this){return _c('div',{attrs:{"id":"test"}},[_c('p',[_v(_s(_f("sum 4")(message)))]),_v(" "),_c('p',[_v(_s(_f("cal 10 20 10")(message)))]),_v(" "),_c('input',{directives:[{name:"model",rawName:"v-model",value:(message | change),expression:"message | change"}],attrs:{"type":"text"},domProps:{"value":(message | change)},on:{"input":function($event){if($event.target.composing)return;message | change=$event.target.value}}})])}

This is my HTML file:这是我的 HTML 文件:

(found in <Root>)

   <!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>vue</title>
        <script src="D:\library\vue.js"></script>
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    </head>
    <body>
        <div id="test">
            <p>{{ message | sum 4 }}</p>
            <p>{{ message | cal 10 20 10 }}</p>  

            <input type="text" v-model="message | change"> 

        </div>
        <script type="text/javascript">

//        -----------------------------------------model->view---------------------------------------
            Vue.filter("sum", function(value) {   
                return value + 4;
            });

            Vue.filter('cal', function (value, begin, xing) {   
                return value + begin + xing;
            });

//        -----------------------------------------view->model---------------------------------------
            Vue.filter("change", {
                read: function (value) { 
                    return value;
                },
                write: function (newVal,oldVal) { 
                    console.log("newVal:"+newVal); 
                    console.log("oldVal:"+oldVal);
                    return newVal;
                }
            });

            var myVue = new Vue({
                el: "#test",
                data: {
                    message:12
                }
            });

        </script>
    </body>
</html>

I learn vue.js these days,and I found it funny.but this is a big mistake that make me headache......Is there any grammar mistakes?How can I do for this mistake?这几天学vue.js,觉得好笑。但是这是一个让我头疼的大错误……有语法错误吗?这个错误怎么办? And what's the meaning of the error?错误的含义是什么? Thank you very much.非常感谢。

In Vue 2.0 (unlike 1.0) you pass arguments to a filter like this:在 Vue 2.0(与 1.0 不同)中,您将参数传递给过滤器,如下所示:

<p>{{ message | cal(10, 20, 10) }}</p>

https://v2.vuejs.org/v2/guide/syntax.html#Filters https://v2.vuejs.org/v2/guide/syntax.html#Filters

And the other issue is the filter in the v-model , Vue 2.0 doesn't support them as is, you can implement them but it's a little bit complicated ( https://v2.vuejs.org/v2/guide/migration.html#Two-Way-Filters-replaced ).另一个问题是v-model中的过滤器,Vue 2.0 不支持它们,你可以实现它们,但它有点复杂( https://v2.vuejs.org/v2/guide/migration. html#Two-Way-Filters-replaced )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM