请问uni-app自定义组件嵌套,子组件无法获取prop值如何解决?
\components\iview\col\index.vue
<template>
<view class="i-row">
<slot></slot>
</view>
</template>
<script>
export default {
name: 'iRow'
}
</script>
<style lang="less">
@import "./index.less";
</style>
\components\iview\row\index.vue
<template>
<view :class="[iClass, 'i-col', span ? 'i-col-' + span : '', offset ? 'i-col-' + offset : '']">
<slot></slot>
</view>
</template>
<script>
export default {
name: "iCol",
props: {
span: {
type: Number,
value: 0
},
offset: {
type: Number,
value: 0
},
iClass: {
type: String,
value: ''
}
},
data() {
return {
}
}
}
</script>
<style lang="less">
@import "./index.less";
</style>
\pages\index\index.vue
i-col 单独使用可以获取span值,嵌套在i-row里就不行了,麻烦看下怎么回事哈?搞不懂,是哪里不对还是说这是mpvue的限制?
<template>
<view>
<i-row> -->
<i-col span="6">
span-6
</i-col>
</i-row>
<i-col span="6">span-6</i-col>
<text class="title">{{title}}</text>
</view>
</template>
<script>
import demo from '../../components/demo/index.vue'
import iRow from '../../components/iview/row/index.vue'
import iCol from '../../components/iview/col/index.vue'
export default {
components:{
demo,
iIcon,
iRow,
iCol
},
data: {
title: 'Hello'
}
}
</script>
<style>
</style>
xpanda (作者)
还是不行,麻烦看一下,谢谢,不支持slot的话感觉很不适应啊,mpvue 目前已经支持slot,uni-app考不考虑跟进哈~~ 积分不够,不能发附件啊
2018-09-04 11:44
Neil_HL
@ixpanda@qq.com:已经给你加积分了,你发个附件试试
2018-09-04 12:11