自定义组件Components出现jsEnginScriptError
发布于 6 年前 作者 whuang 5484 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)
  • 相关代码
#组件的index.js(/components/entrance/index.js)
 
Component({
    properties: {
        title: {
            type: String
        }
    },
    data: {},
    methods: {
        labeltap: function() {
            console.log("label被点击了一下!")
        }
    }
})
 
#组件的index.json (/components/entrance/index.json)
{
  "component": true
}
 
#组件的index.wxml (/components/entrance/index.wxml)
<view>
  <checkbox id="checkbox" checked=""></checkbox>
  <label for="checkbox" class="label" bindtap="labeltap"> {{title}} </label>
</view>
 
----------使用组件---------
#index.json
{
  "navigationBarTitleText": "",
  "usingComponents": {
    "entrance": "/components/entrance/index"
  }
}
 
# index.wxml
 
<view>
<entrance>
      <view>这里是插入到组件slot中的内容</view>
 </entrance>
</view>

困惑点:

  1. errorCode出现得没有指示性,不明所以。。

  2. 这个使用自定义组件的过程,到底哪里出问题呢?

回到顶部