0.0.2 • Published 4 years ago

herb-plugin-framework-extends v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

herb-plugin-framework-extends

安装使用

tnpm i herb-plugin-framework-extends -S
// herb.config.js
module.exports = {
  dev: {
    plugins: []
  },
  plugins: [
    "herb-plugin-framework-extends"
  ]
}

如何在 TypeScript 中获得语法提示

配置 tsconfig.json

{
  "compilerOptions": {
    // ..此处省略其他配置
    "types": [
      "./node_modules/herb-plugin-framework-extends/types"
    ]
  }
}

.ts 文件中使用

以 Page 为例子,Component 同理

import { Page } from 'herbjs';

interface IPageData {}

// 关键是此处,page method 的 interface 只需要 extends IHerbFrameworkExtendsInterface 即可
// 如果 page method 是 type 形式,则 type IPageMethods = {} & IHerbFrameworkExtendsInterface;
interface IPageMethods extends IHerbFrameworkExtendsInterface {
}

Page<IPageData, IPageMethods, IPageStore>({
  // 此处省略代码
  onLoad() {
    // 此处即可获得语法提示
    this.$commitWithoutRender({});
  }
})