VUE 入门
VUE 指令
VUE 方法
VUE 计算属性
VUE 观察者
VUE 扩展
VUE 组件
VUE 插槽
VUE 引用
VUE 生命周期钩子
VUE 提供/注入
VUE 路由
VUE 动画
VUE 构建

Menu
×
×
正确

练习:

编写缺失的代码,使得在单击<div>标记时调用'writeText'方法。

<div id="app"> <p>click on the box below:</p> <div v-on:click="writeText"> {{ text }} </div> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { text: '' } }, methods: { writeText() { this.text = 'Hello World!' } } }) app.mount('#app') </script>
<div id="app"> <p>click on the box below:</p> <div v-on:click='writeText'> {{ text }} </div> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { text: '' } }, methods: { writeText() { this.text = 'Hello World!' } } }) app.mount('#app') </script>
<div id="app"> <p>click on the box below:</p> <div @:click='writeText'> {{ text }} </div> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { text: '' } }, methods: { writeText() { this.text = 'Hello World!' } } }) app.mount('#app') </script>
<div id="app"> <p>click on the box below:</p> <div @:click="writeText"> {{ text }} </div> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { text: '' } }, methods: { writeText() { this.text = 'Hello World!' } } }) app.mount('#app') </script>

不正确

点击 此处 重试

正确

下一题 ❯
<div id="app">
  <p>click on the box below:</p>
  <div =>
    {{ text }}
  </div>
</div>

<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
  const app = Vue.createApp({
    data() {
      return {
        text: ''
      }
    },
    : {
      writeText() {
        this. = 'Hello World!'
      }
    }
  })
  app.mount('#app')
</script>







×

重置分数?