taro icon indicating copy to clipboard operation
taro copied to clipboard

Vite 模式下对小程序原生组件的模板语法 {{}} 解析问题

Open linzhou559 opened this issue 1 year ago • 1 comments

相关平台

微信小程序

复现仓库

https://github.com/linzhou559/taro-vite-wxml-template-bug.git 小程序基础库: 3.4.6 使用框架: React

复现步骤

在 Vite 模式下,小程序原生组件的 wxml 模板中使用 {{}} 语法会导致编译错误。Webpack 模式下同样的代码可以正常工作。

期望结果

vite下可以正常解析

实际结果

报错

[Error: ENOENT: no such file or directory, open '/Users/kl/jlz/Code/myApp/src/components/native-test/{{src}}'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/kl/jlz/Code/myApp/src/components/native-test/{{src}}'
}

环境信息

👽 Taro v3.6.19


  Taro CLI 3.6.19 environment info:
    System:
      OS: macOS 14.2.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
      Yarn: 1.22.19 - /opt/homebrew/bin/yarn
      npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
    npmPackages:
      @tarojs/cli: 4.0.7 => 4.0.7 
      @tarojs/components: 4.0.7 => 4.0.7 
      @tarojs/helper: 4.0.7 => 4.0.7 
      @tarojs/plugin-framework-react: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-alipay: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-h5: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-jd: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-qq: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-swan: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-tt: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-weapp: 4.0.7 => 4.0.7 
      @tarojs/react: 4.0.7 => 4.0.7 
      @tarojs/runtime: 4.0.7 => 4.0.7 
      @tarojs/shared: 4.0.7 => 4.0.7 
      @tarojs/taro: 4.0.7 => 4.0.7 
      babel-preset-taro: 4.0.7 => 4.0.7 
      eslint-config-taro: 4.0.7 => 4.0.7 
      react: ^18.0.0 => 18.3.1 

linzhou559 avatar Dec 03 '24 06:12 linzhou559

同遇到这个问题...

aomnisz avatar Jun 06 '25 07:06 aomnisz

+1,搞了一天都没解决。。。

baojunGit avatar Jun 19 '25 05:06 baojunGit

也遇到这个问题,真的是疯了,框架问题太多了,应该是没人力维护了。经常到无法解决的程度,真不应该入坑的。一个问题卡个一两天,怎么都不行。什么方案都不行,还要自己写shell脚本对编译结果进行修改才行。

chenyuanluck avatar Aug 05 '25 02:08 chenyuanluck