parent
285e64bbed
commit
76b3003182
11
src/index.js
11
src/index.js
|
@ -6,7 +6,7 @@
|
|||
|
||||
import './init.js'
|
||||
import { html, css, Component } from 'wkit'
|
||||
import { noop } from './utils.js'
|
||||
import { noop, readonlyProp } from './utils.js'
|
||||
import { __ROUTER__, __STORE__, __ROUTER_VIEW__ } from './constants.js'
|
||||
|
||||
export * from './router/index.js'
|
||||
|
@ -26,12 +26,18 @@ export function createApp({
|
|||
return new (function () {
|
||||
App.props = data
|
||||
App.styles = styles
|
||||
Object.assign(App.prototype, methods, { mounted })
|
||||
Object.assign(App.prototype, methods, {
|
||||
mounted,
|
||||
created() {
|
||||
readonlyProp(Component.prototype, '$app', this)
|
||||
}
|
||||
})
|
||||
|
||||
this.use = function (plugin = noop, ...args) {
|
||||
plugin.apply(App.prototype, args)
|
||||
return this
|
||||
}
|
||||
|
||||
this.mount = function () {
|
||||
let $router = window.wkitd.get(__ROUTER__)
|
||||
if (render) {
|
||||
|
@ -71,6 +77,7 @@ export function createApp({
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($router) {
|
||||
App.prototype.mounted = function (...args) {
|
||||
let $view = window.wkitd.get(__ROUTER_VIEW__)
|
||||
|
|
10
src/utils.js
10
src/utils.js
|
@ -9,11 +9,13 @@ const decode = decodeURIComponent
|
|||
|
||||
export function noop() {}
|
||||
|
||||
export function hideProp(host, name, value) {
|
||||
export function readonlyProp(host, name, value) {
|
||||
Object.defineProperty(host, name, {
|
||||
value,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
get() {
|
||||
return value
|
||||
},
|
||||
set(vale) {},
|
||||
enumerable: false
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue