M
M
moskwin682019-04-26 18:40:29
Vue.js
moskwin68, 2019-04-26 18:40:29

Create a Vue component and an event inside it?

Task: create a component with a slider that changes the font size in the block.

<div id="controls">
 <font-size target="headline"></font-size>
<div>

My component:
Vue.component('font-size', {
  props: ['target'],
  template: '<div id="controls-item"><input type="range" value="30"></div>'
});
new Vue({ 
  el: '#controls',
})

How to make it so that the following function is executed when the input is onchange: I'm trying to get the type:
function fontResize(selector, target) { }
template: '<div id="controls-item"><input type="range" value="30" onchange="fontResize(this, ' {{ target }} ')"></div>'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-04-26
@moskwin68

You don't need to process any events, v-model + watch is fine.
UPD. "No need" is a joke. It is possible with a subscription to the event, and the code will be even shorter .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question