Здравствуйте. Есть такой фрагмент кода:
const MyTemplateCanvas = { name: 'MyTemplateCanvas', template: '#my-template-canvas', watch: { width (width) { this.canvas.width = width; }, height (height) { this.canvas.height = height; } }, computed: { width () { return this.$ parent.width; }, height () { return this.$ parent.height; }, computedDatatime (index) { return this.sectionDatetime.dateTime.length; } }, data () { return { canvas: { width: '', height: '', stroke:'gray' }, chart: { x: 50, y: 50, width: 260, height: 160, fill: "gray", stroke: "#2a1725", strokeWidth: 2 }, wrapDatetime: { x: 52, y: 178, width: 256, height: 30, fill: "#fff", stroke: "#fff", strokeWidth: 2 }, sectionDatetime: { x: 51, y: 177, width: 2, height: 32, fill: "blue", dateTime: [1, 2, 3], } } } };
<script id="my-template-canvas" type="text/x-template"> <v-stage :config="canvas"> <v-layer> <v-rect :config="chart"></v-rect> <v-rect :config="wrapDatetime"></v-rect> <v-rect :config="sectionDatetime" v-for="(item, index) in computedDatatime" :key="item.id"> </v-rect> </v-layer> </v-stage> </script>
В коде содержится следующий элемент:
<v-rect :config="sectionDatetime" v-for="(item, index) in computedDatatime" :key="item.id"> </v-rect>
Вопрос: Каким способом я могу ‘приконектить’ к элементу событие ‘mounted’. В данном случае на сколько я понимаю – если прописать монтирование в js коде то это будет монтирование ко всему глобальному елементу (id=”my-template-canvas”). Если необходимо этот элемент(v-rect) зарегистрировать отдельно для этого – то каким образом это можно реализовать?
Полную версию кода можно увидеть здесь: https://jsfiddle.net/Mike_kharkov/Lres2bzv/