@vert/core
Version:
Library to build OOP applications which are based on Vue.
167 lines (143 loc) • 2.7 kB
Markdown
# Create app.
App is the entry for an app.
```typescript
import { App } from '@vert/core'
import RootComponent from './layout/default.vue'
const app = new App({
element: '#my-app',
RootComponent
})
app.start()
```
If you want to destroy it:
```typescript
app.destroy()
```
## API
```typescript
/**
* App is the basic unit for a project.
*
* @class App
*/
class App {
/**
* Register target as a singleton provider in global.
*
* @static
* @template T
* @param {TConstructor[]} Providers
*/
static addSingleton (...Providers: TConstructor[]): typeof App
/**
* Register target as a transient provider in global.
*
* @static
* @template T
* @param {TConstructor[]} Providers
*/
static addTransient (...Providers: TConstructor[]): typeof App
/**
* Name of this app instance.
*
* @type {string}
* @readonly
* @memberof App
*/
get name (): string
/**
* Vue store object of this app,
*
* @type {*}
* @readonly
* @memberof App
*/
get store (): any
/**
* View model of this app,
*
* @type {Vue}
* @readonly
* @memberof App
*/
get viewModel (): Vue
/**
* Root component constructor.
*
* @readonly
* @type {TRootComponent}
* @memberof App
*/
get RootComponent (): TRootComponent
/**
* Start up this app.
*
* @memberof App
*/
start (): void
constructor (option: IAppOption)
}
/**
* Constructor param of AppPage.
*
* @interface IAppPage
*/
interface IAppOption {
/**
* HTML element to mount.
*
* @type {(string | HTMLElement)}
* @memberof IAppOption
*/
element?: string | HTMLElement
/**
* You can specify a name for this app instance.
*
* @type {string}
* @memberof IAppOption
*/
name?: string
/**
* Root component the root vue component.
*
* @type {TRootComponent}
* @memberof IAppOption
*/
RootComponent: TRootComponent
/**
* Vue router instance for this app.
*
* @type {*}
* @memberof IAppOption
*/
router?: any
/**
* Vuex instance for this app.
*
* @type {*}
* @memberof IAppOption
*/
store?: any
/**
* Created hook.
*
* @type {THookFunction}
* @memberof IAppOption
*/
created?: THookFunction
/**
* Mounted hook.
*
* @type {THookFunction}
* @memberof IAppOption
*/
mounted?: THookFunction
/**
* Before destroy hook.
*
* @type {THookFunction}
* @memberof IAppOption
*/
beforeDestroy?: THookFunction
}
```