mirror of
https://gitee.com/dcloud/uni-preset-vue
synced 2026-01-30 00:05:29 +08:00
feat(vue3): add ts template
This commit is contained in:
@@ -31,13 +31,12 @@ async function generate (dir, files, base = '', rootOptions = {}) {
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = (api, options, rootOptions) => {
|
||||
module.exports = (api, options, rootOptions) => {
|
||||
api.extendPackage(pkg => {
|
||||
return {
|
||||
dependencies: {
|
||||
'regenerator-runtime': '^0.12.1',// 锁定版本,避免高版本在小程序中出错
|
||||
'@dcloudio/uni-helper-json': '*',
|
||||
'vuex': '^4.0.0-beta.4'
|
||||
'@dcloudio/uni-helper-json': '*'
|
||||
},
|
||||
devDependencies: {
|
||||
'postcss-comment': '^2.0.0',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"vueVersion": "3",
|
||||
"useConfigFiles": false,
|
||||
"plugins": {
|
||||
"@dcloudio/vue-cli-plugin-uni": {
|
||||
|
||||
@@ -5,6 +5,9 @@ module.exports = [{
|
||||
choices: [{
|
||||
name: '默认模板',
|
||||
value: 'default'
|
||||
},{
|
||||
name: '默认模板(TypeScript)',
|
||||
value: 'default-ts'
|
||||
}
|
||||
],
|
||||
default: 'None'
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
export default Vue.extend({
|
||||
mpType: 'app',
|
||||
import {
|
||||
defineComponent
|
||||
} from 'vue'
|
||||
export default defineComponent({
|
||||
onLaunch() {
|
||||
console.log('App Launch')
|
||||
},
|
||||
@@ -11,9 +12,8 @@
|
||||
onHide() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/*每个页面公共css */
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import Vue from 'vue'
|
||||
import App from './App.vue'
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
new App().$mount()
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
|
||||
createApp(App).mount('#app')
|
||||
|
||||
@@ -1,41 +1,39 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<view class="content">
|
||||
<image class="logo" src="../../static/logo.png"></image>
|
||||
<view>
|
||||
<text class="title">{{title}}</text>
|
||||
<view>
|
||||
<text class="title">{{ title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
export default Vue.extend({
|
||||
data() {
|
||||
return {
|
||||
title: 'Hello'
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
||||
}
|
||||
});
|
||||
<script lang="ts">
|
||||
import {
|
||||
defineComponent
|
||||
} from "vue";
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
return {
|
||||
title: "hello",
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.content {
|
||||
text-align: center;
|
||||
height: 400upx;
|
||||
}
|
||||
.logo{
|
||||
.content {
|
||||
text-align: center;
|
||||
height: 400upx;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 200upx;
|
||||
width: 200upx;
|
||||
margin-top: 200upx;
|
||||
}
|
||||
.title {
|
||||
font-size: 36upx;
|
||||
color: #8f8f94;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 36upx;
|
||||
color: #8f8f94;
|
||||
}
|
||||
</style>
|
||||
|
||||
4
template/default-ts/sfc.d.ts
vendored
4
template/default-ts/sfc.d.ts
vendored
@@ -1,4 +0,0 @@
|
||||
declare module "*.vue" {
|
||||
import Vue from 'vue'
|
||||
export default Vue
|
||||
}
|
||||
5
template/default-ts/shims-vue.d.ts
vendored
Normal file
5
template/default-ts/shims-vue.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
declare module "*.vue" {
|
||||
import type { DefineComponent } from "vue";
|
||||
const component: DefineComponent<{}, {}, any>;
|
||||
export default component;
|
||||
}
|
||||
5
template/default-ts/uni-app.d.ts
vendored
Normal file
5
template/default-ts/uni-app.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import "vue";
|
||||
declare module "vue" {
|
||||
type Hooks = App.AppInstance & Page.PageInstance;
|
||||
interface ComponentCustomOptions extends Hooks {}
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
<script>
|
||||
import {
|
||||
onLaunch,
|
||||
onShow,
|
||||
onHide
|
||||
} from 'vue'
|
||||
export default {
|
||||
setup() {
|
||||
onLaunch(() => console.log('App Launch'))
|
||||
onShow(() => console.log('App Show'))
|
||||
onHide(() => console.log('App Hide'))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/*每个页面公共css */
|
||||
<script>
|
||||
export default {
|
||||
onLaunch() {
|
||||
console.log('App Launch')
|
||||
},
|
||||
onShow() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/*每个页面公共css */
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user