英文:
Why v-slider (Vuetify) has no width?
问题
只有默认的空v-slider标记没有宽度或拇指居中对齐:
这个粗点是滑块的拇指,没有滑块条。
<div v-if="typeList[0] === 'grade'" class="formItem__grade">
<v-radio-group v-model="item.value" inline>
<v-radio v-for="el in item.meta.answers" :label="el" :value="el" :disabled="disable"></v-radio>
</v-radio-group>
<!--
<v-slider v-model:model-value="item.value"
:ticks="item.meta.answers"
:max="item.meta.answers.length"
show-ticks="always"
step="1"
tick-size="3"
></v-slider>
-->
<v-slider></v-slider>
</div>
在已注释的代码中,您可以看到我尝试设置属性,但没有成功。因此,我尝试了没有任何属性的<v-slider>
(如图像中所示),但也不起作用。
英文:
I want to create a v-slider, but just on default empty v-slider tag has no width or thumb align center:
This bold point is the thumb of slider and no one slider bar.
<div v-if="typeList[0] === 'grade'" class="formItem__grade">
<v-radio-group v-model="item.value" inline>
<v-radio v-for="el in item.meta.answers" :label="el" :value="el" :disabled="disable"></v-radio>
</v-radio-group>
<!--
<v-slider v-model:model-value="item.value"
:ticks="item.meta.answers"
:max="item.meta.answers.length"
show-ticks="always"
step="1"
tick-size="3"
></v-slider>
-->
<v-slider></v-slider>
</div>
In the commented code, you can see that I tried to set props, but it did not work. So I tried <v-slider>
without any props (as in the image), but it does not work either.
答案1
得分: 0
这是您要翻译的代码部分,不要有别的内容:
"That happens when you don't wrap your Vuetify components into a v-app
. It works when you do:
const { createApp, ref } = Vue;
const { createVuetify} = Vuetify;
const vuetify = createVuetify();
const App = {
setup() {
return {
sliderVal1: ref(25),
sliderVal2: ref(1),
item: {meta: {
answers: ['a1', 'a2']
}},
isVapp: ref(true)
};
}
};
const app = createApp(App);
app.use(vuetify).mount('#app');
<link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdn.jsdelivr.net/npm/vuetify@3.1.6/dist/vuetify.min.css\" />
<div id=\"app\">
<label><input type=\"checkbox\" v-model=\"isVapp\"/> with v-app</label>
<component :is=\"isVapp ? 'VApp' : 'div'\">
<div>
<v-slider v-model=\"sliderVal1\" />
</div>
{{sliderVal1}}
<div>
<v-slider
v-model=\"sliderVal2\"
:ticks=\"Object.fromEntries(Object.entries(item.meta.answers))\"
:max=\"item.meta.answers.length - 1\"
show-ticks=\"always\"
step=\"1\"
tick-size=\"3\"
color=\"blue\"
/>
</div>
{{sliderVal2}}
</component>
</div>
<script src=\"https://unpkg.com/vue@3/dist/vue.global.prod.js\"></script>
<script src=\"https://cdn.jsdelivr.net/npm/vuetify@3.1.6/dist/vuetify.min.js\"></script>
请注意,这是代码的翻译部分。
英文:
That happens when you don't wrap you Vuetify components into a v-app
. It works when you do:
<!-- begin snippet: js hide: false console: false babel: false -->
<!-- language: lang-js -->
const { createApp, ref } = Vue;
const { createVuetify} = Vuetify
const vuetify = createVuetify()
const App = {
setup() {
return {
sliderVal1: ref(25),
sliderVal2: ref(1),
item: {meta: {
answers: ['a1', 'a2']
}},
isVapp: ref(true)
}
}
}
const app = createApp(App)
app.use(vuetify).mount('#app')
<!-- language: lang-html -->
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/vuetify@3.1.6/dist/vuetify.min.css" />
<div id="app">
<label><input type="checkbox" v-model="isVapp"/> with v-app</label>
<component :is="isVapp ? 'VApp' : 'div'">
<div>
<v-slider v-model="sliderVal1" />
</div>
{{sliderVal1}}
<div>
<v-slider
v-model="sliderVal2"
:ticks="Object.fromEntries(Object.entries(item.meta.answers))"
:max="item.meta.answers.length - 1"
show-ticks="always"
step="1"
tick-size="3"
color="blue"
/>
</div>
{{sliderVal2}}
</component>
</div>
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@3.1.6/dist/vuetify.min.js"></script>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论