") == -1) { html = " " + html; } html = html.replace("",""); html = html.replace("",""); html = html.replace("",""); html = html.trim(); doc.innerHTML = html; return ( doc.innerHTML.toLowerCase() === html.toLowerCase() ); } function codeCheckWarningClose() { document.getElementById("codeCheckWarning").style.display = "none"; } function codeCheckCorrectClose() { document.getElementById("codeCheckCorrect").style.display = "none"; }
菜单
×
×
正确!

练习

编写缺失的代码,以便当值低于 40 时,观察者激活警告类。

<div id="app"> <input type="range" v-model="rangeVal"> <p :class="{ warnClass: warnActive }"><code>{{ rangeVal }}</code></p> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { rangeVal: 70, warnActive: false } }, watch: { rangeVal(val) { if(val<40){ this.warnActive = true; } else{ this.warnActive = false; } } } }) app.mount('#app') </script>

不正确

点击这里重新尝试。

正确!

下一题 ❯
<div id="app"> <input type="range" v-model="rangeVal"> <p :class="{ warnClass: warnActive }"><code>{{ rangeVal }}</code></p> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { rangeVal: 70, warnActive: false } }, watch: {  { if(val<40){ this.warnActive = true; } else{ this.warnActive = false; } } } }) app.mount('#app') </script>

    
  




 

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

×

重置分数?

这将重置所有 54 道练习的分数。

您确定要继续吗?



×

恭喜!

您已完成所有 54 道 VUE 练习。

分享您的分数