Vue.directive('custom', { inserted: function(el) { el.style.backgroundColor = 'orange' } }) var app = new Vue({ el: '#app' })
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="app"> <input v-custom type="text"> <input v-waves type="text"> <!-- The `v-waves` directive will have the same error --> </div>
The reason is that there is no custom directive registered. For more usage of custom directives, please see here .
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.