悠闲的程序员
悠闲的程序员
  • 发布:2019-07-19 19:17
  • 更新:2021-02-04 16:42
  • 阅读:936

【报Bug】自定义组件无法正常编译到字节跳动小程序

分类:uni-app

详细问题描述

uni-app中使用了自定义组件,示例代码如下:
page中代码如下:
<template>
<view>
<test he="测试"></test>
<image style="width:200px; height: 200px;background-color: red;" @error="imgError" mode="aspectFill" src="../../static/home.png" />
<view v-for="(item,index) in stories" :key="index">
{{item.name}}
</view>
<button @click="change">该表</button>
</view>
</template>
<script>
import test from '../../components/test.vue'
export default {
components:{
test
},
data() {
return {
stories: []
}
},
methods: {
change() {
var that = this
that.stories = [{
name:"test"
},{
"name":"wrewjdlgj"
}]
}
}
}
</script>
<style>
</style>

组件代码如下:
<template>
<view>
<image style="width:200px; height: 200px;background-color: red;" @error="imgError" mode="aspectFill" src="../static/home.png" />
<text>{{he}}</text>
</view>
</template>

<script>
export default {
props: ["he"],
data() {
return {
};
},
mounted() {
console.log(this.he)
},
methods: {
imgError(e) {
console.log("图片加载失败。。。。")
console.log(e)
}
}
}
</script>

<style>
.img {
width: 100rpx;
height: 100rpx;
}
</style>

编译后的字节跳动小程序,json文件中usingComponents为空"{}",这里我注意到hbuilderx是将自定义组件的js文件编译到页面中了。但是自定义组件中的图片无法加载,报错是404,烦请技术人员看下是什么原因。

IDE运行环境说明

HBuilderX 2.1.1.20190716
macOS Mojave10.14.5 (18F132

联系方式

925258809

2019-07-19 19:17 负责人:无 分享
已邀请:
xiaokar

xiaokar - 一名对代码整洁度有强迫症的专业前端

这么久还没解决,那我提的问题也是无望了

xiaokar

xiaokar - 一名对代码整洁度有强迫症的专业前端

老哥有解决麻烦回复下https://github.com/dcloudio/uni-app/issues/2463

该问题目前已经被锁定, 无法添加新回复