|
1 | 1 | ## Noticebar 通告栏 |
2 | 2 |
|
3 | 3 | ### 使用指南 |
4 | | -在 app.wxss 中引入组件库所有样式 |
5 | | -```css |
6 | | -@import "path/to/zanui-weapp/dist/index.wxss"; |
| 4 | +在 index.json 中引入组件 |
| 5 | +```json |
| 6 | +{ |
| 7 | + "usingComponents": { |
| 8 | + "zan-noticebar": "path/to/zanui-weapp/dist/noticebar/index" |
| 9 | + } |
| 10 | +} |
| 11 | +``` |
| 12 | + |
| 13 | +在 index.js 中声明组件数据 |
| 14 | +```js |
| 15 | +// 在 Page 中声明 Noticebar 依赖的展示数据 |
| 16 | +Page({ |
| 17 | + data: { |
| 18 | + text: 'xxx', |
| 19 | + scrollable: 'xxx', |
| 20 | + ... |
| 21 | + } |
| 22 | +}) |
7 | 23 | ``` |
8 | 24 |
|
9 | | -在需要使用的页面里引入组件库模板和脚本 |
| 25 | +### 代码演示 |
| 26 | +`Noticebar` 组件支持滚动和静止两种展示方式,通过 text 传入展示文案 |
| 27 | + |
| 28 | +### 静止公告栏 |
10 | 29 | ```html |
11 | | -<import src="path/to/zanui-weapp/dist/noticebar/index.wxml" /> |
| 30 | +<zan-noticebar |
| 31 | + text="{{ text }}" |
| 32 | +/> |
| 33 | +``` |
12 | 34 |
|
13 | | -<!-- 直接使用 zan-noticebar 模板,并且直接传入设置值 --> |
14 | | -<template is="zan-noticebar" data="{{ ...data, componentId: 'noticebar' }}"></template> |
| 35 | +### 滚动通告栏 |
| 36 | +```html |
| 37 | +<zan-noticebar |
| 38 | + text="{{ text }}" |
| 39 | + scrollable="true" |
| 40 | +/> |
15 | 41 | ``` |
16 | 42 |
|
17 | | -// 在 Page 中混入 Noticebar 里面声明的方法 |
18 | | -```js |
19 | | -const { Noticebar, extend } = require('path/to/zanui-weapp/dist/index'); |
| 43 | +### 延时滚动通告栏 |
| 44 | +```html |
| 45 | +<zan-noticebar |
| 46 | + text="{{ text }}" |
| 47 | + scrollable="true" |
| 48 | + delay="{{ delay }}" |
| 49 | +/> |
| 50 | +``` |
20 | 51 |
|
21 | | -Page(extend({}, Noticebar, { |
22 | | - // ... |
23 | | -})); |
| 52 | +### 改变滚动通告栏滚动速度 |
| 53 | +```html |
| 54 | +<zan-noticebar |
| 55 | + text="{{ text }}" |
| 56 | + scrollable="true" |
| 57 | + speed="{{ speed }}" |
| 58 | +/> |
24 | 59 | ``` |
25 | 60 |
|
26 | | -### 代码演示 |
27 | | -`Noticebar` 组件支持滚动和静止两种展示方式,通过 text 传入展示文案 |
| 61 | +### 自定义通告栏字体颜色和背景色 |
28 | 62 | ```html |
29 | | -<template is="zan-noticebar" data="{{ text: '展示文案', componentId: 'noticebar' }}"></template> |
| 63 | +<zan-noticebar |
| 64 | + text="{{ text }}" |
| 65 | + color="{{ color }}" |
| 66 | + background-color="{{ backgroundColor }}" |
| 67 | +/> |
30 | 68 | ``` |
31 | 69 |
|
32 | | -**注意** |
| 70 | +### 添加左侧icon通告栏 |
| 71 | +```html |
| 72 | +<zan-noticebar |
| 73 | + text="{{ text }}" |
| 74 | + left-icon="https://img.yzcdn.cn/public_files/2017/8/10/6af5b7168eed548100d9041f07b7c616.png" |
| 75 | +/> |
| 76 | +``` |
33 | 77 |
|
34 | | -如果组件需要开启滚动展示,需要在 Page 的脚本中执行 initZanNoticeBarScroll 方法,来开启滚动展示 |
35 | | -```js |
36 | | -Page(extend({}, Noticebar, { |
37 | | - // ... |
38 | | - onShow() { |
39 | | - // 在方法中传入对应的 componentId |
40 | | - this.initZanNoticeBarScroll('movable'); |
41 | | - } |
42 | | - // ... |
43 | | -})); |
| 78 | +### 可关闭通告栏 |
| 79 | +```html |
| 80 | +<zan-noticebar |
| 81 | + text="{{ text }}" |
| 82 | + mode="closeable" |
| 83 | +/> |
44 | 84 | ``` |
45 | 85 |
|
46 | | -| 参数 | 说明 | 类型 | 默认值 | 必须 | |
| 86 | +| 参数 | 说明 | 类型 | 默认值 | 可选值 | |
47 | 87 | |-----------|-----------|-----------|-------------|-------------| |
48 | 88 | | text | 通告栏展示文案 | String | - | | |
49 | | -| componentId | 用于区分页面多个 Noticebar 组件,在调用 initZanNoticeBarScroll 时需要传入 | String | - | | |
| 89 | +| mode | 通告栏模式 | String | '' | `closeable` | |
| 90 | +| delay | 滚动延时时间 | Number | 0 | | |
| 91 | +| speed | 滚动速度 | Number | 40 | | |
| 92 | +| scrollable | 是否可滚动 | Boolean | false | | |
| 93 | +| leftIcon | 左侧图标 | String | - | | |
| 94 | +| color | 通告栏字体颜色 | String | `#f60` | | |
| 95 | +| backgroundColor | 通告栏背景色 | String | `#fff7cc` | |
0 commit comments