使用自定义组件提示错误
发布于 5 年前 作者 ucheng 14878 次浏览 来自 问答

使用自己定义的oast组件提示错误:(toast组件又使用了(嵌套了)一个自定义的icon组件)
Error:** Expect END descriptor with depth 1 but get another

根据调试发现可能是嵌套icon(icon有个属性叫做icon,是图标的样式)的问题,

<wxc-toast is-show="{{$toast.show}}" text="分享成功" icon="yes" icon-color="#ff5777"></wxc-toast>
<button bindtap="showToast">自定义 icon 颜色的 toast</button>

去掉icon属性后使用正常不会报错,一旦加上icon就会报错 Expect END descriptor with depth 1 but get another

<wxc-toast is-show="{{$toast.show}}" text="分享成功" icon-color="#ff5777"></wxc-toast>
<button bindtap="showToast">自定义 icon 颜色的 toast</button>
console.group("Mon Nov 13 2017 11:05:41 GMT+0800 (中国标准时间) 渲染层错误")
console.error(Error: Expect END descriptor with depth 1 but get another)
console.groupEnd()



win10系统;
微信开发者工具最新版v1.01.1711020;

请教大神这个错误一般是如何引起的?

7 回复

手机上会有问题吗?

代码基本上就是些样式,js的话就是定义几个properties属性,问题就是wxc-toast嵌套wxc-icon的时候出现了问题,

调用自定义组件的时候加上icon属性就不行,不加就没事,希望大神们尽快解决这个问题,多谢啦

wxc-icon.wxml: 


<view class="icon icon--{{type}}" style="font-size:{{size}}rpx; color:{{color}};"></view>


wxc-toast.wxml:


<view class="toast" wx:if="{{isShow}}">
    <view class="toast__box">
        <view wx:if="{{icon || iconImage}}" class="toast__icon" style="color: {{iconColor || '#fff'}}">
            <block wx:if="{{icon && !iconImage}}">
                <wxc-icon type="{{icon}}" size="68"></wxc-icon>
            </block>
             
            <image wx:if="{{iconImage}}" class="toast__icon--image" src="{{iconImage}}" mode="widthFix"></image>
        </view>
 
        <text class="toast__title">
            <slot wx:if="{{!text}}"></slot>{{text ? text : ''}}
        </text>
    </view>

</view>


wxc-icon.js:


Component({

options: {},

behaviors: [],

properties: {

type: {

type: String,

value: ''

},

size: {

type: [Number, String],

value: 26

},

color: {

type: String,

value: '#333333'

}

},


data: {},


created: function () {},

attached: function () {},

ready: function () {},

moved: function () {},

detached: function () {},


methods: {


}

})



wxc-toast.js:


Component({

options: {},

behaviors: [],

properties: {

isShow: {

type: Boolean,

value: false

},

text: {

type: String,

value: ''

},

icon: {

type: String,

value: ''

},

iconColor: {

type: String,

value: ''

},

iconImage: {

type: String,

value: ''

},

duration: {

type: Number,

value: 2000

}

},


data: {

maskStatus: 'hide'

},


created: function () {},

attached: function () {

console.log(this.data.icon);

},


ready: function () {},

moved: function () {},

detached: function () {},


methods: {

}

})



index.wxml:


<wxc-toast is-show="{{$toast.show}}" text="分享成功" icon="yes" icon-color="#ff5777"></wxc-toast>

    <button bindtap="showToast">自定义 icon 颜色的 toast</button>



index.js:


showToast() {

   this.setData({

     $toast: {

       show: true

     }

   })

   setTimeout(() => {

     this.setData({

       $toast: {

         show: false

       }

     })

   }, 1500)

 },











你好,这应该是基础库内部的一个错误。麻烦提供一下代码以便我们分析问题,谢谢!

最新的基础库版本1.6.4

我没有能够用你的代码来复现问题。请问你用的是哪个版本的基础库呢?

回到顶部