第一步 安装cli
npm install -g @vue/cli
第二步 新建项目
npx degit dcloudio/uni-preset-vue#vite-ts my-vue3-project
第三步新建文件,在pages/index 文件夹下新建test.vue 文件
<template>
<div>
文字
</div>
</template>
<script setup lang='ts'>
import { ref, withDefaults } from 'vue'
</script>
<style scoped>
</style>
第四步 在pages/index 文件夹下的index.vue 文件中导入并使用这个文件
<template>
<view class="content">
<image class="logo" src="/static/logo.png" />
<view class="text-area">
<text class="title">{{ title }}</text>
</view>
<test></test>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import test from './test.vue'
const title = ref('Hello')
</script>
第五步 ,编译成微信小程序
在终端运行
yarn dev:mp-weixin
1***@qq.com (作者)
我六月14号用cli创建的项目的时候,还是可以编译成小程序,为什么才过了一个月就用不行了。
两个版本的package.json 是不同的版本,这种情况应该 还是在更新吧
2024-07-16 09:18
1***@qq.com (作者)
回复 1***@qq.com: 看了一下ts的package.json模版最新一次的更新还在18天前
2024-07-16 09:37