Vue學習(1)創建

安裝

npm install vue

引用

<script type="text/javascript" src="./node_modules/vue/dist/vue.js"></script>

新建vue對象

var x = new Vue({
            el: '#app',
            data: {
                msg: '黃瓜',
                str: 'hello'
            },
            template: ''
        })

{{}} 引用

<div id="app">
        <h2>{{msg}}</h2>
        <h3>{{1 + 1}}</h3>
    </div>

在這裏插入圖片描述

代碼

<!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>
</head>

<body>
    <div id="app">
        <h2>{{msg}}</h2>
        <h3>{{1 + 1}}</h3>
    </div>
    <script type="text/javascript" src="./node_modules/vue/dist/vue.js"></script>
    <script type="text/javascript">
        var x = new Vue({
            el: '#app',
            data: {
                msg: '黃瓜',
                str: 'hello'
            },
            template: ''
        })
        console.log(x.$el)

        console.log(x.$data)
    </script>
</body>

</html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章