98 lines
1.9 KiB
Markdown
98 lines
1.9 KiB
Markdown
|
## Wkitd
|
||
|
> 基于`wkit`封装的一个应用框架, 提供`store`和`router`等基础服务。
|
||
|
|
||
|
![downloads](https://img.shields.io/npm/dt/wkitd.svg)
|
||
|
![version](https://img.shields.io/npm/v/wkitd.svg)
|
||
|
|
||
|
### 开发文档
|
||
|
[开发文档](https://github.com/bytedo/wkitd/wikid)
|
||
|
|
||
|
|
||
|
### 我们的特色
|
||
|
|
||
|
- 提供迷你的单页应用开发环境
|
||
|
- 无需`node.js`编译, 即写即用。
|
||
|
|
||
|
|
||
|
|
||
|
### 示例
|
||
|
|
||
|
|
||
|
app.js
|
||
|
|
||
|
```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
|
||
|
|
||
|
```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":"https://jscdn.ink/lib/es.shim.js",
|
||
|
"wkit":"https://jscdn.ink/lib/wkit.js",
|
||
|
"fetch":"https://jscdn.ink/lib/fetch.js",
|
||
|
"@bd/ui/":"https://jscdn.ink/@bd/ui/latest/"
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
<script type="module" src="/app.js"></script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<wc-app></wc-app>
|
||
|
</body>
|
||
|
</html>
|
||
|
```
|