mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-08-07 13:09:45 +08:00
[new feature] NoticeBar: support use inner icon (#2305)
This commit is contained in:
parent
c100b045d1
commit
ce225ea18b
@ -3,7 +3,7 @@
|
|||||||
<demo-block :title="$t('basicUsage')">
|
<demo-block :title="$t('basicUsage')">
|
||||||
<van-notice-bar
|
<van-notice-bar
|
||||||
:text="$t('text')"
|
:text="$t('text')"
|
||||||
left-icon="//img.yzcdn.cn/vant/volume.png"
|
left-icon="volume-o"
|
||||||
/>
|
/>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ Vue.use(NoticeBar);
|
|||||||
```html
|
```html
|
||||||
<van-notice-bar
|
<van-notice-bar
|
||||||
text="Only those who have the patience to do simple things perfectly ever acquire the skill to do difficult things easily."
|
text="Only those who have the patience to do simple things perfectly ever acquire the skill to do difficult things easily."
|
||||||
left-icon="//img.yzcdn.cn/vant/volume.png"
|
left-icon="volume-o"
|
||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -46,11 +46,10 @@ Vue.use(NoticeBar);
|
|||||||
| delay | Animation delay (s) | `Number` | `1` |
|
| delay | Animation delay (s) | `Number` | `1` |
|
||||||
| speed | Scroll speed (px/s) | `Number` | `50` |
|
| speed | Scroll speed (px/s) | `Number` | `50` |
|
||||||
| scrollable | Whether to scroll content | `Boolean` | `true` |
|
| scrollable | Whether to scroll content | `Boolean` | `true` |
|
||||||
| left-icon | Image url of left icon | `String` | - |
|
| left-icon | Left Icon | `String` | - |
|
||||||
| color | Text color | `String` | `#f60` |
|
| color | Text color | `String` | `#f60` |
|
||||||
| background | Background color | `String` | `#fff7cc` |
|
| background | Background color | `String` | `#fff7cc` |
|
||||||
|
|
||||||
|
|
||||||
### Event
|
### Event
|
||||||
|
|
||||||
| Event | Description | Arguments |
|
| Event | Description | Arguments |
|
||||||
|
@ -17,21 +17,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__left-icon {
|
&__left-icon {
|
||||||
height: 18px;
|
font-size: 16px;
|
||||||
min-width: 20px;
|
min-width: 20px;
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
img {
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__right-icon {
|
&__right-icon {
|
||||||
top: 12px;
|
top: 50%;
|
||||||
right: 15px;
|
right: 15px;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
margin-top: -0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__wrap {
|
&__wrap {
|
||||||
|
@ -5,12 +5,11 @@
|
|||||||
:style="barStyle"
|
:style="barStyle"
|
||||||
@click="$emit('click')"
|
@click="$emit('click')"
|
||||||
>
|
>
|
||||||
<div
|
<icon
|
||||||
v-if="leftIcon"
|
v-if="leftIcon"
|
||||||
:class="b('left-icon')"
|
:class="b('left-icon')"
|
||||||
>
|
:name="leftIcon"
|
||||||
<img :src="leftIcon">
|
/>
|
||||||
</div>
|
|
||||||
<div
|
<div
|
||||||
ref="wrap"
|
ref="wrap"
|
||||||
:class="b('wrap')"
|
:class="b('wrap')"
|
||||||
@ -73,7 +72,7 @@ export default create({
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
iconName() {
|
iconName() {
|
||||||
return this.mode === 'closeable' ? 'close' : this.mode === 'link' ? 'arrow' : '';
|
return this.mode === 'closeable' ? 'cross' : this.mode === 'link' ? 'arrow' : '';
|
||||||
},
|
},
|
||||||
|
|
||||||
barStyle() {
|
barStyle() {
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
exports[`renders demo correctly 1`] = `
|
exports[`renders demo correctly 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<div class="van-notice-bar" style="color:undefined;background:undefined;">
|
<div class="van-notice-bar" style="color:undefined;background:undefined;"><i class="van-icon van-icon-volume-o van-notice-bar__left-icon" style="color:undefined;font-size:undefined;">
|
||||||
<div class="van-notice-bar__left-icon"><img src="//img.yzcdn.cn/vant/volume.png"></div>
|
<!---->
|
||||||
|
<!----></i>
|
||||||
<div class="van-notice-bar__wrap">
|
<div class="van-notice-bar__wrap">
|
||||||
<div class="van-notice-bar__content" style="padding-left:0;animation-delay:1s;animation-duration:0s;">足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。</div>
|
<div class="van-notice-bar__content" style="padding-left:0;animation-delay:1s;animation-duration:0s;">足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。</div>
|
||||||
</div>
|
</div>
|
||||||
@ -25,7 +26,7 @@ exports[`renders demo correctly 1`] = `
|
|||||||
<!---->
|
<!---->
|
||||||
<div class="van-notice-bar__wrap">
|
<div class="van-notice-bar__wrap">
|
||||||
<div class="van-notice-bar__content" style="padding-left:0;animation-delay:1s;animation-duration:0s;">足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。</div>
|
<div class="van-notice-bar__content" style="padding-left:0;animation-delay:1s;animation-duration:0s;">足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。</div>
|
||||||
</div> <i class="van-icon van-icon-close van-notice-bar__right-icon" style="color:undefined;font-size:undefined;">
|
</div> <i class="van-icon van-icon-cross van-notice-bar__right-icon" style="color:undefined;font-size:undefined;">
|
||||||
<!---->
|
<!---->
|
||||||
<!----></i>
|
<!----></i>
|
||||||
</div>
|
</div>
|
||||||
|
@ -14,7 +14,7 @@ Vue.use(NoticeBar);
|
|||||||
```html
|
```html
|
||||||
<van-notice-bar
|
<van-notice-bar
|
||||||
text="足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。"
|
text="足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。"
|
||||||
left-icon="//img.yzcdn.cn/vant/volume.png"
|
left-icon="volume-o"
|
||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ Vue.use(NoticeBar);
|
|||||||
| delay | 动画延迟时间 (s) | `Number` | `1` | - |
|
| delay | 动画延迟时间 (s) | `Number` | `1` | - |
|
||||||
| speed | 滚动速率 (px/s) | `Number` | `50` | - |
|
| speed | 滚动速率 (px/s) | `Number` | `50` | - |
|
||||||
| scrollable | 是否在长度溢出时滚动播放 | `Boolean` | `true` | - |
|
| scrollable | 是否在长度溢出时滚动播放 | `Boolean` | `true` | - |
|
||||||
| left-icon | 左侧图标图片 URL | `String` | - | - |
|
| left-icon | 左侧图标名称或图片链接,可选值见 Icon 组件 | `String` | - | - |
|
||||||
| color | 文本颜色 | `String` | `#f60` | - |
|
| color | 文本颜色 | `String` | `#f60` | - |
|
||||||
| background | 滚动条背景 | `String` | `#fff7cc` | - |
|
| background | 滚动条背景 | `String` | `#fff7cc` | - |
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user