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