I have started using Vuetify, but I am looking for a way to modify the default props on some components.Is there a way to do this?i.e. Instead of constantly having to write:<v-layout wrap></v-layout>Can I make layouts default prop for wrap be true? 解决方案 something along these lines, but beware if you are new to vue.js you'll have to do some reading:relevant doc: vue mixin, vue extendsjs// some already existing component, you need to get it somehow// most likely via `import <something-to-import>`let theExternalComponent = { props: { wrap: { default: false, type: Boolean } }, template: "<li>wrap:{{wrap}}</li>"};// this simulates the global registrationVue.component("v-some-external-component", theExternalComponent);// -- lets start --// lets extend that component - and overwrite the default prop for wraplet extendedExternalwithOtherDefaults = { extends: theExternalComponent, mixins: [{ props: { wrap: { default: true } } }],};var app = new Vue({ el: "#app", components: { "v-my-customized-component": extendedExternalwithOtherDefaults }});html (pug actually but that does not matter here)div(id="app") ul v-some-external-component v-some-external-component(wrap) v-my-customized-component // now defaults to wrap:true v-my-customized-component(:wrap="false") // you can still set the wrap to false if requiredoutputwrap:falsewrap:truewrap:truewrap:falsecodepen: https://codepen.io/anon/pen/MLxbEW 这篇关于Vuetify,如何设置默认道具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-13 04:44