wepy如何使用typescript来开发自己的项目?

网站管理员 Published the article • 0 comments • 10 views • 2019-08-05 15:37 • 来自相关话题

how to create wepy applicate writen in typescript?

### install and config

```bash
npm install @wepy/compiler-typescript typescript --save-dev
```

in `wepy.config.js`
```js
const TypeScriptCompiler = require('@wepy/compiler-typescript');

module.exports = {
"plugins": [
TypeScriptCompiler()
]
};
```

### 如何在wepy的文件中引入ts文件和项目

```

{{age}}



```

### ts文件

```ts
import wepy from '@wepy/core'

wepy.page({
data: {
age: 1
},
created() {
console.log(this.age)
},
computed: {

},
hooks: {

},
methods: {

}
})
```


### 引用

1. [compiler-typescript](https://wepyjs.github.io/wepy- ... script) 查看全部

how to create wepy applicate writen in typescript?

### install and config

```bash
npm install @wepy/compiler-typescript typescript --save-dev
```

in `wepy.config.js`
```js
const TypeScriptCompiler = require('@wepy/compiler-typescript');

module.exports = {
"plugins": [
TypeScriptCompiler()
]
};
```

### 如何在wepy的文件中引入ts文件和项目

```



```

### ts文件

```ts
import wepy from '@wepy/core'

wepy.page({
data: {
age: 1
},
created() {
console.log(this.age)
},
computed: {

},
hooks: {

},
methods: {

}
})
```


### 引用

1. [compiler-typescript](https://wepyjs.github.io/wepy- ... script)