diff --git a/src/notice-bar/__test__/__snapshots__/demo.test.jsx.snap b/src/notice-bar/__test__/__snapshots__/demo.test.jsx.snap
index cb8880a76..b8f058b3d 100644
--- a/src/notice-bar/__test__/__snapshots__/demo.test.jsx.snap
+++ b/src/notice-bar/__test__/__snapshots__/demo.test.jsx.snap
@@ -5,11 +5,7 @@ exports[`NoticeBar > NoticeBar baseVue demo works fine 1`] = `
class="t-notice-bar t-notice-bar--info"
>
-
-
-
+
NoticeBar baseVue demo works fine 1`] = `
style=""
>
这是一条普通的通知信息
-
-
-
+
@@ -69,11 +61,7 @@ exports[`NoticeBar > NoticeBar customVue demo works fine 1`] = `
style=""
>
提示文字描述提示文字描述提示文字描述
-
-
-
+
@@ -285,11 +273,7 @@ exports[`NoticeBar > NoticeBar eventVue demo works fine 1`] = `
style=""
>
这是一条普通的通知信息
-
-
-
+
@@ -346,11 +330,7 @@ exports[`NoticeBar > NoticeBar iconDemoVue demo works fine 1`] = `
style=""
>
提示文字描述提示文字描述提示文字描述
-
-
-
+
@@ -397,11 +377,7 @@ exports[`NoticeBar > NoticeBar mobileVue demo works fine 1`] = `
class="t-notice-bar t-notice-bar--info"
>
-
-
-
+
NoticeBar mobileVue demo works fine 1`] = `
style=""
>
这是一条普通的通知信息
-
-
-
+
@@ -471,11 +443,7 @@ exports[`NoticeBar > NoticeBar mobileVue demo works fine 1`] = `
style=""
>
提示文字描述提示文字描述提示文字描述
-
-
-
+
@@ -531,11 +499,7 @@ exports[`NoticeBar > NoticeBar mobileVue demo works fine 1`] = `
style=""
>
这是一条普通的通知信息
-
-
-
+
@@ -683,11 +647,7 @@ exports[`NoticeBar > NoticeBar mobileVue demo works fine 1`] = `
style=""
>
这是一条普通的通知信息
-
-
-
+
@@ -767,11 +727,7 @@ exports[`NoticeBar > NoticeBar mobileVue demo works fine 1`] = `
style=""
>
提示文字描述提示文字描述提示文字描述
-
-
-
+
@@ -945,11 +901,7 @@ exports[`NoticeBar > NoticeBar mobileVue demo works fine 1`] = `
style=""
>
默认状态公告栏默认状态公告栏
-
-
-
+
@@ -985,11 +937,7 @@ exports[`NoticeBar > NoticeBar mobileVue demo works fine 1`] = `
style=""
>
成功状态公告栏成功状态公告栏
-
-
-
+
@@ -1025,11 +973,7 @@ exports[`NoticeBar > NoticeBar mobileVue demo works fine 1`] = `
style=""
>
警示状态公告栏警示状态公告栏
-
-
-
+
@@ -1065,11 +1009,7 @@ exports[`NoticeBar > NoticeBar mobileVue demo works fine 1`] = `
style=""
>
错误状态公告栏错误状态公告栏
-
-
-
+
@@ -1105,11 +1045,7 @@ exports[`NoticeBar > NoticeBar mobileVue demo works fine 1`] = `
class="t-notice-bar t-notice-bar--info notice-bar-demo-block"
>
-
-
-
+
NoticeBar mobileVue demo works fine 1`] = `
style=""
>
提示文字描述提示文字描述提示文字描述提示文字描述文
-
-
-
+
@@ -1159,11 +1091,7 @@ exports[`NoticeBar > NoticeBar mobileVue demo works fine 1`] = `
style=""
>
提示文字描述提示文字描述提示文字描述提示文字描述文
-
-
-
+
@@ -1298,11 +1226,7 @@ exports[`NoticeBar > NoticeBar scrollingVue demo works fine 1`] = `
class="t-notice-bar t-notice-bar--info notice-bar-demo-block"
>
-
-
-
+
NoticeBar scrollingVue demo works fine 1`] = `
style=""
>
提示文字描述提示文字描述提示文字描述提示文字描述文
-
-
-
+
@@ -1352,11 +1272,7 @@ exports[`NoticeBar > NoticeBar scrollingVue demo works fine 1`] = `
style=""
>
提示文字描述提示文字描述提示文字描述提示文字描述文
-
-
-
+
@@ -1510,11 +1426,7 @@ exports[`NoticeBar > NoticeBar suffixIconVue demo works fine 1`] = `
style=""
>
这是一条普通的通知信息
-
-
-
+
@@ -1575,11 +1487,7 @@ exports[`NoticeBar > NoticeBar themeVue demo works fine 1`] = `
style=""
>
默认状态公告栏默认状态公告栏
-
-
-
+
@@ -1615,11 +1523,7 @@ exports[`NoticeBar > NoticeBar themeVue demo works fine 1`] = `
style=""
>
成功状态公告栏成功状态公告栏
-
-
-
+
@@ -1655,11 +1559,7 @@ exports[`NoticeBar > NoticeBar themeVue demo works fine 1`] = `
style=""
>
警示状态公告栏警示状态公告栏
-
-
-
+
@@ -1695,11 +1595,7 @@ exports[`NoticeBar > NoticeBar themeVue demo works fine 1`] = `
style=""
>
错误状态公告栏错误状态公告栏
-
-
-
+
diff --git a/src/notice-bar/__test__/index.test.jsx b/src/notice-bar/__test__/index.test.jsx
index e8f59883f..0cd454ae6 100644
--- a/src/notice-bar/__test__/index.test.jsx
+++ b/src/notice-bar/__test__/index.test.jsx
@@ -156,7 +156,7 @@ describe('NoticeBar', async () => {
triggerName = name;
});
const wrapper = mount(
- ,
+ ,
);
await wrapper.find('.t-notice-bar__prefix-icon').trigger('click');
expect(triggerName).toBe('prefix-icon');
diff --git a/src/notice-bar/demos/event.vue b/src/notice-bar/demos/event.vue
index 0ac8791b7..ef2f1cea1 100644
--- a/src/notice-bar/demos/event.vue
+++ b/src/notice-bar/demos/event.vue
@@ -18,7 +18,6 @@ import { h } from 'vue';
import { CloseIcon, ChevronRightIcon } from 'tdesign-icons-vue-next';
import { Toast } from 'tdesign-mobile-vue';
-const iconFunc = () => h(CloseIcon);
const arrowRight = () => h(ChevronRightIcon);
const handleClick = (context: string) => {
Toast(`click:${context}`);
diff --git a/src/notice-bar/demos/scrolling.vue b/src/notice-bar/demos/scrolling.vue
index 93efa0014..24de218ca 100644
--- a/src/notice-bar/demos/scrolling.vue
+++ b/src/notice-bar/demos/scrolling.vue
@@ -14,5 +14,4 @@ import { SoundIcon } from 'tdesign-icons-vue-next';
const content = ref('提示文字描述提示文字描述提示文字描述提示文字描述文');
const content1 = ref(['君不见', '高堂明镜悲白发', '朝如青丝暮成雪', '人生得意须尽欢', '莫使金樽空对月']);
-const visible = ref(true);
diff --git a/src/notice-bar/notice-bar.en-US.md b/src/notice-bar/notice-bar.en-US.md
index cfa265eff..e1c06782d 100644
--- a/src/notice-bar/notice-bar.en-US.md
+++ b/src/notice-bar/notice-bar.en-US.md
@@ -9,7 +9,7 @@ content | String / Array / Slot / Function | - | Typescript:`string \| string[
direction | String | horizontal | options:horizontal/vertical | N
marquee | Boolean / Object | false | Typescript:`boolean \| DrawMarquee` `interface DrawMarquee { speed?: number; loop?: number; delay?: number }`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/notice-bar/type.ts) | N
operation | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
-prefixIcon | Boolean / Slot / Function | - | Typescript:`Boolean \ | TNode \| Function`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
+prefixIcon | Boolean / Slot / Function | true | Typescript:`Boolean \ | TNode `。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
suffixIcon | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
theme | String | info | options:info/success/warning/error | N
visible | Boolean | false | `v-model` and `v-model:visible` is supported | N
diff --git a/src/notice-bar/notice-bar.md b/src/notice-bar/notice-bar.md
index 975820186..e38030f0b 100644
--- a/src/notice-bar/notice-bar.md
+++ b/src/notice-bar/notice-bar.md
@@ -9,7 +9,7 @@ content | String / Array / Slot / Function | - | 文本内容。TS 类型:`str
direction | String | horizontal | 滚动方向。可选项:horizontal/vertical | N
marquee | Boolean / Object | false | 跑马灯效果。speed 指速度控制;loop 指循环播放次数,值为 -1 表示循环播放,值为 0 表示不循环播放;delay 表示延迟多久开始播放。TS 类型:`boolean \| DrawMarquee` `interface DrawMarquee { speed?: number; loop?: number; delay?: number }`。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/notice-bar/type.ts) | N
operation | String / Slot / Function | - | 右侧额外信息。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
-prefixIcon | Boolean / Slot / Function | - | 前缀图标。 值为 false 表示不显示前缀图标。TS 类型:`Boolean \ | TNode \ | Function`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
+prefixIcon | Boolean / Slot / Function | true | 用于自定义g公告栏前面的图标,优先级大于 theme 设定的图标。值为 false 则不显示图标,值为 true 显示 theme 设定图标。TS 类型:`Boolean \ | TNode `。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
suffixIcon | Slot / Function | - | 后缀图标。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
theme | String | info | 内置主题。可选项:info/success/warning/error | N
visible | Boolean | false | 显示/隐藏。支持语法糖 `v-model` 或 `v-model:visible` | N
diff --git a/src/notice-bar/notice-bar.vue b/src/notice-bar/notice-bar.vue
index 87d4c5aca..abd8dbc58 100644
--- a/src/notice-bar/notice-bar.vue
+++ b/src/notice-bar/notice-bar.vue
@@ -1,7 +1,11 @@
-
handleClick('prefix-icon')">
+
handleClick('prefix-icon')"
+ >
@@ -30,17 +34,13 @@
@transitionend="handleTransitionend()"
>
-
handleClick('operation')">
+ handleClick('operation')">
- handleClick('suffix-icon')"
- >
+
handleClick('suffix-icon')">
@@ -101,19 +101,10 @@ export default defineComponent({
const rootClasses = computed(() => [`${name}`, `${name}--${props.theme}`]);
// prefix-icon
- const prefixIconContent = computed(() => {
- let iconContent = null;
- if (typeof props.prefixIcon === 'boolean' && props.prefixIcon === false) {
- return;
- }
- if (props.prefixIcon || context.slots.prefixIcon) {
- iconContent = renderTNode(internalInstance, 'prefixIcon');
- } else {
- const key = props.theme as string;
- iconContent = iconDefault?.[key] || null;
- }
- return iconContent;
- });
+ const prefixIconContent = computed(() =>
+ renderTNode(internalInstance, 'prefixIcon', { defaultNode: iconDefault[props.theme || 'info'] }),
+ );
+
// suffix-icon
const suffixIconContent = computed(() => renderTNode(internalInstance, 'suffixIcon'));
// operation
diff --git a/src/notice-bar/props.ts b/src/notice-bar/props.ts
index c2a145652..fba26d89e 100644
--- a/src/notice-bar/props.ts
+++ b/src/notice-bar/props.ts
@@ -33,7 +33,7 @@ export default {
/** 前缀图标 */
prefixIcon: {
type: [Boolean, Function] as PropType,
- default: null,
+ default: true,
},
/** 后缀图标 */
suffixIcon: {