美文网首页
uni-app使用slot插槽不生效的问题

uni-app使用slot插槽不生效的问题

作者: WMSmile | 来源:发表于2022-09-14 12:39 被阅读0次

uni-app使用slot插槽不生效的问题

slot <slot> 元素作为组件模板之中的内容分发插槽。<slot> 元素自身将被替换。详情看vue 官方文档

最近使用z-paging的demo时,遇到了slot使用不能生效的问题。

<view class="top-nav" slot="top">
    <view class="head-nav">
        <!-- 你的代码 -->
    </view>
</view>

解决思路如下:

查看问题:slot 一直未编译,最后发现写法上变了。参考了uni-list-item的重写的代码

解决方式如下:

<template v-slot:top>
    <view class="top-nav">
        <view class="head-nav">
            <!-- 你的代码 -->
        </view>
    </view>
</template>

到此,解决完毕!

相关文章

  • uni-app使用slot插槽不生效的问题

    uni-app使用slot插槽不生效的问题 slot 元素作为组件模板之中的内容分发插槽。 元素自身将被替换...

  • vue插槽

    vue插槽slot的理解与使用 vue slot插槽的使用介绍及总结

  • 插槽

    插槽的基础使用,

  • Vue插槽:slot、slot-scope与指令v-slot使用

    不具名插槽 具名插槽 v-slotv-slot在组件中使用slot进行占位时,也是在slot标签内使用name 属...

  • 小程序组件插槽

    匿名插槽 使用时,用 slot 属性来将节点插入到不同的slot上。 实名插槽 使用时,用 slot 属性来将节点...

  • Vue01组件化实践-03 插槽 slot

    组件化 slot 插槽 demo github地址:feature/slot 分支 直接上代码体会插槽的使用吧

  • slot是什么?有什么作用?原理是什么?

    slot又名插槽,是Vue的内容分发机制,组件内部的模板引擎使用slot元素作为承载分发内容的出口。插槽slot是...

  • slot(插槽)

    slot又称插槽,是Vue的内容分发机制,组件内部的模板引擎使用slot元素作为承载分发内容的出口。插槽slot是...

  • vue 插槽的使用

    vue 插槽手册 深入理解vue中的slot与slot-scope 插槽的使用其实是很简单首先要明白插槽是使用在子...

  • Vue 小知识点汇总

    插槽slot 如何使用slot的同时传数据(v-slot:name="value") situation: 父页面...

网友评论

      本文标题:uni-app使用slot插槽不生效的问题

      本文链接:https://www.haomeiwen.com/subject/kfnkortx.html