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

how to create wepy applicate writen in typescript?

install and config

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

in wepy.config.js

const TypeScriptCompiler = require('@wepy/compiler-typescript');

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

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

<template>
    <view>{{age}}</view>
</template>

<script lang="typescript" src ="./index.ts"></script>

ts文件

import wepy from '@wepy/core'

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

  },
  hooks: {

  },
  methods: {

  }
})

引用

  1. compiler-typescript

0 comments

To reply to the article, please Login or registered