gpt4 book ai didi

css - 如何在 iView 中自定义输入元素的 CSS?

转载 作者:行者123 更新时间:2023-11-28 02:17:21 25 4
gpt4 key购买 nike

我用的是Vue的单文件组件,想试试iView UI框架。考虑有以下代码:

<template>
<div>
<i-input class="cred"/>
</div>
</template>

然后我想改变输入的宽度。例如,检查更改是否生效:

<style scoped>
input {
width: 10px;
}
</style>

但是没有效果。也尝试了 i-input

<style scoped>
.cred {
width: 10px;
}
</style>

按预期工作。
我应该使用哪个 CSS 选择器?

最佳答案

Vue/iView 允许您使用内联 style 属性并为其传递宽度,或者您可以更改 .ivu-input-wrapper CSS 类并给它with 你想要的。

Vue.use(iview);
new Vue({
data() {
return {
value: ''
}
}
}).$mount('#app')
@import url("//unpkg.com/iview/dist/styles/iview.css");
#app {
padding: 32px;
}

.ivu-input-wrapper {
width: 400px;
}
<script src="//unpkg.com/vue/dist/vue.min.js"></script>
<script src="//unpkg.com/iview/dist/iview.min.js"></script>
<div id="app">
<i-input v-model="value" placeholder="CSS changed..."></i-input>
<i-input v-model="value" placeholder="Inline style changed..." style="width: 200px"></i-input>
</div>

关于css - 如何在 iView 中自定义输入元素的 CSS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48389573/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com