Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新建默认模板,H5无法调用图片 #7869

Closed
netzhouxiang opened this issue Oct 20, 2020 · 4 comments · Fixed by #7872
Closed

新建默认模板,H5无法调用图片 #7869

netzhouxiang opened this issue Oct 20, 2020 · 4 comments · Fixed by #7872
Labels
F-vue2 Framework - Vue 2 T-h5 Target - 编译到 H5 V-3 Version - 3.x
Milestone

Comments

@netzhouxiang
Copy link

相关平台

H5

复现仓库

https://github.com/netzhouxiang/taro_test
浏览器版本: Chrome
使用框架: Vue 2

复现步骤

1.按步骤创建(Vue2 TypeScript Sass)项目,使用默认模板
2.添加src/resource文件夹(包含banner图片),修改pages/index/index,增加image标签引入图片../../resource/banner.png
3.直接npm run dev:h5;浏览器不显示
4.如果配置h5: {imageUrlLoaderOption: {esModule: false}},则tabbar图标又不显示

期望结果

正常显示图片

实际结果

不显示图片

环境信息

👽 Taro v3.0.14

  Taro CLI 3.0.14 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 10.11.0 - C:\Program Files\nodejs\node.EXE
      npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD

补充信息

有没有可能是node版本导致,我最近做区块链给node降级了,降到 v10.11.0 了

@taro-bot2 taro-bot2 bot added F-vue2 Framework - Vue 2 T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Oct 20, 2020
@luckyadam
Copy link
Member

你好,这是 taro 的问题,目前可以通过以下写法绕过,不用自行配置 esModule 配置

<template>
  <view class="index">
    <text>{{ msg }}</text>
    <image :src="banner"></image>
  </view>
</template>

<script>
import banner from '../../resource/banner.png'
import './index.scss'

export default {
  data () {
    return {
      msg: 'Hello world!',
      banner
    }
  }
}
</script>

@luckyadam
Copy link
Member

#7872 这个 pr 将修复这个问题,版本发布后可以支持直接使用 src 引用图片

@netzhouxiang
Copy link
Author

netzhouxiang commented Oct 20, 2020

好的

@Midas-Li
Copy link

现在我用taro+react+taroui+ts,也是h5,也是有这个问题。还没更新,希望能解决。谢谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue2 Framework - Vue 2 T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
4 participants