m***@163.com
m***@163.com
  • 发布:2023-07-13 18:27
  • 更新:2023-07-13 18:51
  • 阅读:174

uniapp 打包原生 app 的模块化异常问题

分类:uni-app
<template>  
  <view class="content">  
    <image  
      :style="{ width: '46px' }"  
      :src="getImg('menu/close.png')"  
      mode="widthFix"  
    />  
    <view class="text-area">  
      <text class="title">{{ title }}</text>  
    </view>  
  </view>  
</template>  

<script>  
import { getImg } from '../../utils/assets.js'  
export default {  
  data() {  
    return {  
      title: 'Hello',  
    }  
  },  
  onLoad() {},  
  methods: {},  
}  
</script>

18:19:56.376 [Vue warn]: Unhandled error during execution of render function
at <IndexpageId=1pagePath="pages/index/index"__pageQuery={} ...>
18:19:56.385 TypeError: _ctx.getImg is not a function

我愿意付费咨询,起码100

2023-07-13 18:27 负责人:无 分享
已邀请:
爱tutu爱生活

爱tutu爱生活 - 前端渣渣

检查下getImg函数吧

m***@163.com

m***@163.com (作者)

export const getImg = (imgPath) => {  
  return new URL(`/src/assets/images/${imgPath}`, import.meta.url).href;  
};

getImg就是一个简单的引入图片的函数,我用的是vue3.0 打包原生app,但是如果在组件里面引入一个组件或者一个函数都会报错,h5不会报错,但是打包成原生app就会报错,感觉是打包成app的时候模块化出现了问题

m***@163.com

m***@163.com (作者)

有人有信心处理的吗?我加到200,有意向的找我私聊

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