wkitd

1.3.10 • Public • Published

Wkitd

基于wkit封装的一个应用框架, 提供storerouter等基础服务。

downloads version

开发文档

开发文档

我们的特色

  • 提供迷你的单页应用开发环境
  • 无需node.js编译, 即写即用。
  • 本项目适合开发一些快速迭代简单页面、app内嵌的webview页面(无须搭建复杂的前端开发环境)

一些注意事项

  • 路由不支持嵌套, 即<router-view></router-view>只能出现1次。
  • $router对象, 只注入到使用wkit创建的组件, 其他地方可以使用getRouter()获取$router对象。
  • 所有路由页面和组件, 均可使用getCurrentPage()获取当前的页面的信息; 也可以用$route$router.route获取。
  • $store对象, 只注入到使用wkit创建的组件, 其他组件可使用getStore()获取。
  • watch()方法, 可用于监听$store$route的变化。

示例

app.js

// alias wkitd='//jscdn.ink/wkitd/latest/index.js'
import { css, html, createApp, createRouter, createWebHistory, createStore } from 'wkitd'


const store = createStore({
  foo: 123,
  bar: 456
})

import './views/home.js' // <wc-home />

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      name: 'wc-home' // element tagname !importent
    },
    {
      path: '/about',
      name: 'wc-about',
      component: () => import('./views/about.js')
    }
  ]
})


createApp({
  data:{},
  methods: {},
  render(){
    return html`
    <div class="app">
      <router-view></router-view>
    </div>`
  }
})
.use(store)
.use(router)
.mount()

index.html

<!doctype html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
  <title>wkitd example</title>
  <meta name="keywords" content="">
  <meta name="description" content="">
  <link href="" rel="stylesheet">
  <script type="importmap">
    {
      "imports":{
        "es.shim":"//jscdn.ink/es.shim/latest/index.js",
        "wkit":"//jscdn.ink/wkit/latest/index.js",
        "wkitd":"//jscdn.ink/wkitd/latest/index.js",
        "fetch":"//jscdn.ink/@bytedo/fetch/latest/next.js",
        "@bd/ui/":"//jscdn.ink/@bd/ui/latest/"
      }
    }
  </script>
  <script type="module" src="/app.js"></script>
</head>
<body>
  <wc-app></wc-app>
</body>
</html>

Readme

Keywords

none

Package Sidebar

Install

npm i wkitd

Weekly Downloads

211

Version

1.3.10

License

none

Unpacked Size

24.4 kB

Total Files

5

Last publish

Collaborators

  • yutent