简体   繁体   中英

vue js extend standard input control e.g. textarea

With vue.js: is it possible to simply extend standard HTML-input without putting it in a wrapper element?

I'd like to extend textarea like this:

Vue.component('custom-textarea', {
  data () => {
    return {
    }
  },
  template: '<textarea></textarea>'
});

I've tried to use the textarea tag as the only and root tag of the vue template, but that hasn't worked at all.

I know, I could achieve a custom textarea by simply wrapping it eg in a DIV-tag like:

template: '<div><textarea></textarea></div>'

So, is there a way at all to avoid the wrapper tag and simply extend textarea in vue.js?

Since you have textarea as the only root element, you can do what you are doing using template: '<textarea></textarea>' . Vue will not complain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM