0

在我的Vue.js( version 2.5.22) 应用程序中,我使用Buefy库中的 UI 组件。我使用taginput元素。如果我有 5 个标签的限制,如下例所示,当输入有 5 个标签时边框消失。

问题:是否有可能改变这种行为?无论如何,我想显示边界。

<b-field label="Limited to 10 characters and 5 tags">
    <b-taginput maxtags="5":value="['Red', 'Green', 'Blue', 'White']">
    </b-taginput>
</b-field>
4

3 回答 3

1

这没有道具。您可以将类属性添加到 b-field 组件标记:

<b-field class="always-show" label="Limited to 10 characters and 5 tags">
    <b-taginput maxtags="5" :value="['Red', 'Green', 'Blue', 'White']">
    </b-taginput>
</b-field>

然后为新类添加样式:

.always-show .taginput-container{
  box-shadow: inset 0 1px 2px hsla(0,0%,4%,.1);
  border: 1px solid #b5b5b5;
  border-radius: 4px;
  padding: calc(.375em - 1px) calc(.625em - 1px);
}
于 2019-01-22T20:39:23.193 回答
1

我有一个建议,也许换一种方式,你不需要修改默认的限制行为: 1.不要限制输入的标签数量。2.添加时确定,如果超过5个,删除第一个。

  • 模板
<b-field label="Limited to 10 characters and 5 tags">
    <b-taginput @add="onAdd" :value="tags">
    </b-taginput>
</b-field>
  • js
data() {
  return {
    tags: []
  }
}
onAdd(){
  if (this.tags.length > 5) {
    this.tags.shift();
  }
}
于 2019-01-23T01:52:04.520 回答
0

好吧,就我而言,我使用这种风格:

<b-field class="always-show" label="Limited to 10 characters and 5 tags">
    <b-taginput maxtags="5" :value="['Red', 'Green', 'Blue', 'White']">
    </b-taginput>
</b-field>

CSS

.always-show .taginput-container {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    height: auto;
    cursor: text;
    border-color: #dbdbdb;
    color: #363636;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    clear: both;
    font-size: 1rem;
    position: relative;
    text-align: left;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 2px rgba(10, 10, 10, 0.1);
    background-color: #fff;
    box-shadow: inset 0 1px 2px hsla(0,0%,4%,.1);
    padding: calc(.375em - 1px) calc(.625em - 1px);
    line-height: 1.5;
  }
于 2019-05-03T07:37:18.333 回答