请老师帮忙查看代码,有误,但是没发现,谢谢
来源:1-11 作用域插槽
叫我丽红
2021-10-14 15:25:32
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>lesson 6</title>
<script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<div id="root"></div>
</body>
<!-- 样式绑定语法 -->
<script>
const app = Vue.createApp({
data(){
return{currentItem:'input-item'}
},
methods:{
handleClick(){
if(this.currentItem === 'input-item'){
this.currentItem === 'common-item';
}else{
this.currentItem === 'input-item';
}
}
},
template:`
<keep-alive>
<component:is="currentItem" />
</keep-alive>
<button @click="handleClick">切换</button>
pas
`
});
app.component('input-item',{
template:`<input />`
});
app.component('common-item',{
template:`<div>hello world</div>`
});
const vm = app.mount('#root');
</script>
</html>
1回答
好帮手慕久久
2021-10-14
同学你好,代码有如下错误:
1、:is属性与其他内容挨着写了,语法不对:
前面要有空格,修改如下:
2、赋值是“=”,不是“===”,修改如下:
祝学习愉快!
相似问题