Comments (2)
是的,是需要wrap一下,我看了下Vue的文档,自己试了wrap一个控件,可以运行,你可以试试哈。
"dependencies": {
"vue": "^2.5.2",
"vue-router": "^3.0.1",
"zeu": "^1.1.1"
},
TextMeter.vue
<template>
<canvas :id="id" :width="width" :height="height"></canvas>
</template>
<script>
import * as zeu from 'zeu';
export default {
name: 'TextMeter',
props: {
id: String,
width: Number,
height: Number,
options: Object,
displayValue: String,
value: Number
},
mounted() {
if (!this.chart) {
this.init();
}
},
watch: {
displayValue(val) {
this.chart.displayValue = val;
},
value(val) {
this.chart.value = val;
}
},
beforeDestroy() {
this.destory();
},
methods: {
init() {
let textMeter = new zeu.TextMeter(this.$el.id, this.options);
textMeter.displayValue = this.displayValue;
textMeter.value = this.value;
this.chart = textMeter;
},
destory() {
this.chart.destroy();
this.chart = null;
}
}
}
</script>
</script>
TestPage.vue
<template>
<div>
<button @click="update">Update</button>
<TextMeter :id="textMeter.id" :width="textMeter.width" :height="textMeter.height"
:displayValue="displayValue" :value="value" :options="textMeter.options"></TextMeter>
</div>
</template>
<script>
import TextMeter from './TextMeter';
export default {
name: 'TestPage',
components: {
TextMeter
},
data () {
return {
textMeter: {
id: 'test',
width: 200,
height: 100,
options: {}
},
displayValue: 'ZEU',
value: 80
}
},
methods: {
update() {
this.displayValue = 'NEW';
this.value = 30;
}
}
}
</script>
from zeu.
谢谢大佬,学到了,很不错
from zeu.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zeu.