首页 >> js开发 >> jsv-slot和slot、slot-scope之间相互替换实例js大全
jsv-slot和slot、slot-scope之间相互替换实例js大全
发布时间: 2021年1月13日 | 浏览:
| 分类:js开发
如果组件文档里面用的是v-slot,而你用的是vue2.6之前的版本,则需要替换v-slot:所以有两种替换方式,注意看两块v-slot有啥不同,你就知道你该怎么用slot-scope和slot来替换文档中的v-slot了v-slot使用方式1:v-slot使用方式1:
则可替换为:
v-slot使用方式2:v-slot使用方式2:
则可替换为:
先记录后期再完善,赶项目去了补充知识:V-for and slot-scoped报错问题补充知识:补充知识:V-for and slot-scoped报错问题此场景是为了用v-for动态渲染表格的slot可能会这么写
{{ text }}
{{ text }}
但是这样子会报错,因为v-for和slot-scope在同一级
Ambiguous combined usage of slot-scope and v-for on (v-for takes higher priority). Use a wrapper < template> for the scoped slot to make it clearer.
Ambiguous combined usage of slot-scope and v-for on (v-for takes higher priority). Use a wrapper < template> for the scoped slot to make it clearer.提示在外边包一层< template>,于是你可能改成下面这样,但是也会报错
{{ text }}
< template> cannot be keyed. Place the key on real elements instead.
{{ text }}
< template> cannot be keyed. Place the key on real elements instead.提示< template>template不能写key, 即使没有这个错,表格数据也不会渲染出来,因为这一层没有slot,应该说slot应该是放最外面,同时把:key放里面改成如下
{{ text }}
{{ text }}
以上解决问题以上解决问题有个slot没有渲染的问题
{{ text }}
{{ text }}
{{ item }}
{{ item }}
{{ text }}
{{ text }}
{{ item }}
{{ item }}
好像是因为2个v-for="(slotname, idx)"里的slotname名字一样了,对的,就是取的临时变量名,修改成不一样的就好了,神奇
// 上面那个name
。。。
。。。
// 上面那个name
。。。
。。。
以上这篇v-slot和slot、slot-scope之间相互替换实例就是小编分享给大家的全部内容了,希望能给大家一个参考。
则可替换为:
v-slot使用方式2:v-slot使用方式2:
则可替换为:
先记录后期再完善,赶项目去了补充知识:V-for and slot-scoped报错问题补充知识:补充知识:V-for and slot-scoped报错问题此场景是为了用v-for动态渲染表格的slot可能会这么写
{{ text }}
{{ text }}
但是这样子会报错,因为v-for和slot-scope在同一级
Ambiguous combined usage of slot-scope and v-for on (v-for takes higher priority). Use a wrapper < template> for the scoped slot to make it clearer.
Ambiguous combined usage of slot-scope and v-for on (v-for takes higher priority). Use a wrapper < template> for the scoped slot to make it clearer.提示在外边包一层< template>,于是你可能改成下面这样,但是也会报错
{{ text }}
< template> cannot be keyed. Place the key on real elements instead.
{{ text }}
< template> cannot be keyed. Place the key on real elements instead.提示< template>template不能写key, 即使没有这个错,表格数据也不会渲染出来,因为这一层没有slot,应该说slot应该是放最外面,同时把:key放里面改成如下
{{ text }}
{{ text }}
以上解决问题以上解决问题有个slot没有渲染的问题
{{ text }}
{{ text }}
{{ item }}
{{ item }}
{{ text }}
{{ text }}
{{ item }}
{{ item }}
好像是因为2个v-for="(slotname, idx)"里的slotname名字一样了,对的,就是取的临时变量名,修改成不一样的就好了,神奇
// 上面那个name
。。。
。。。
// 上面那个name
。。。
。。。
以上这篇v-slot和slot、slot-scope之间相互替换实例就是小编分享给大家的全部内容了,希望能给大家一个参考。
相关文章:
- JavaScript如何将Node.js中的回调转换为Promise
- JavaScriptNode.js path模块,获取文件后缀名操作
- js解决Vue watch里调用方法的坑js大全
- js解决vue init webpack 下载依赖卡住不动的问题js大全
- jsvue-axios同时请求多个接口 等所有接口全部加载完成再处理操作js大全
- js在vue项目中promise解决回调地狱和并发请求的问题js大全
- jsEcharts在Taro微信小程序开发中的踩坑记录js大全
- jsvue 中的动态传参和query传参操作js大全
- js解决Vue大括号字符换行踩的坑js大全
- jsVue 防止短时间内连续点击后多次触发请求的操作js大全