<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h1>{{ msg }}</h1>
        <p>点击次数:{{ count }}</p>
        <button v-on:click="add">点击我</button>
        <p></p>
        <button @click="add">点击我</button>

<hr>

<p>結果:{{ jieguo }}</p>

<input type="text" @keyup.enter="jisuan(30,40)" value=""><br>
<input type="text" @keyup.ctrl.a="jisuan(50,40)" value=""><br>
<input type="text" @keyup.space="jisuan(0,40)" value=""><br>
<input type="text" @keyup.w="jisuan(1,1)" value=""><br>



    </div>
    <script type="module">

        import {createApp,reactive,ref} from './vue.esm-browser.js'

        createApp({

            setup(){

                const count = ref(1)

                const add = () =>{
                    count.value += 1
                }

                const jieguo = ref(0)

                const jisuan = (a1,a2)=>{
                    jieguo.value += a1+a2
                }

                return {
                    msg:'lesson 7',
                    count,
                    add,
                    jisuan,
                    jieguo
                }
            }

        }).mount('#app')


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

标签: none

评论已关闭