Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add window install #19

Merged
merged 2 commits into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion docs/guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ How we can make Tabulator better?

Welcome Vue-Tabulator.

## Getting Started
## Installation

Vue-tabulator is a wrapper to Tabulator, so you need to [install tabulator](http://tabulator.info/docs/4.2/install#sources-npm) to use vue-tabulator.

Expand Down Expand Up @@ -81,6 +81,47 @@ export default {
};
```

### Browser
You can import the vue-tabulator in your browser:

```html
<script src="https://unpkg.com/vue@latest"></script>

<link href="https://unpkg.com/tabulator-tables@4.4.1/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@4.4.1/dist/js/tabulator.min.js"></script>
<script src="https://unpkg.com/vue-tabulator@latest"></script>

<div id="app">
<h1>Vue Tabulator</h1>
<Vue-Tabulator v-model="dados" :options="options" />
</div>


<script>
new Vue({
el: '#app',
data() {
return {
dados: [{
name: 'Teste',
age: 13
}],
options: {
columns: [{
title: 'Name',
field: 'name',
sorter: 'string',
width: 200,
editor: true,
}, ],
}
}
}
});
</script>

```

## Options

The options object can accept any [Tabulator options](http://tabulator.info/docs/4.2/options), which allows you to use the full power of Tabulator on start or configuration.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
],
"main": "./dist/vue-tabulator.umd.js",
"browser": "./dist/vue-tabulator.common.js",
"unpkg": "./dist/vue-tabulator.umd.min.js",
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
Expand Down
14 changes: 10 additions & 4 deletions src/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ import TabulatorComponent from '@/components/TabulatorComponent.vue';

export { TabulatorComponent };

function install(VueApp: typeof Vue, options: any = {}) {
const name = options.name || 'VueTabulator';
VueApp.component(name, TabulatorComponent);
};

export default {
install(VueApp: typeof Vue, options: any = {}) {
const name = options.name || 'VueTabulator';
VueApp.component(name, TabulatorComponent);
},
install,
};

if (typeof window !== 'undefined' && (<any>window).Vue && (<any>window).Vue === Vue) {
install((<any>window).Vue)
}