Wednesday, December 13, 2017

[Vue.js][Resolved] Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead

Error msg :
[Vue warn]: value="{{date}}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div id="{{ val }}">, use <div :id="val">. 
Source Code:
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Untitle</title>
</head>
<body>
    <div id="app">
        <p>
            <label for="date">Date :</label>
            <input name="date" type="date" v-model="date" value="{{date}}"/>
        </p>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.4/vue.js"></script>
    <script>
    var data = {
        "date":"2017-01-03",
    };
    new Vue({
        el:'#app',
        data:data
    });
    </script>
</body>
</html>

What should do is already mentioned in the error message, change the red text to green text mentioned below:

Correction

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Untitle</title>
</head>
<body>
    <div id="app">
        <p>
            <label for="date">Date :</label>
            <input name="date" type="date" v-model="date" :value="date"/>
        </p>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.4/vue.js"></script>
    <script>
    var data = {
        "date":"2017-01-03",
    };
    new Vue({
        el:'#app',
        data:data
    });
    </script>
</body>
</html>

Reference

https://github.com/vuejs/vue/issues/2812

2 comments :