-
下载文档提供的模板:https://gitee.com/dcloud/uni-preset-vue/repository/archive/vite-ts.zip
-
打开,npm i,要报错:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: uni-preset-vue@0.0.0
npm ERR! Found: vite@4.0.4
npm ERR! node_modules/vite
npm ERR! dev vite@"4.0.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vite@"4.0.3" from @dcloudio/vite-plugin-uni@3.0.0-alpha-3061620221230002
npm ERR! node_modules/@dcloudio/vite-plugin-uni
npm ERR! dev @dcloudio/vite-plugin-uni@"3.0.0-alpha-3061620221230002" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
-
手动修改版本号至3.0.0-alpha-3070020230201004,
@dcloudio/vite-plugin-uni
只有 3.0.0-alpha-3070020230201003,再次 npm i,不报错了 -
src文件夹下创建 components/ha-test/ha-test.vue,内容如下:
<template>
<view>123</view>
</template>
<script lang="ts" setup>
</script>
<style lang="scss" scoped></style>
- pages.json 里配置 easycom,
custom
可要可不要,因为加不加都不行
"easycom": {
"autoscan": true,
"custom": {
"^ha-(.*)": "@/components/ha-$1/ha-$1.vue"
}
}
-
pages/index/index.vue 里随便找个地方加上 <ha-test></ha-test>
-
npm run dev:h5,打开页面
Arsenal (作者)
我试了下好像也可以了
2023-02-08 10:41