Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add radio can render content as html.(The advantage is that you can use the icon...) #1472

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion example/pages/radio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
title="右对齐"
v-model="value3"
:options="options3" />

<mt-radio
class="page-part"
title="渲染选项为html元素"
v-model="value4"
renderAsHtml
:options="options4" />
<div>
<mt-cell title="选中的项">{{ value4 }}</mt-cell>
</div>
</div>
</template>

Expand All @@ -37,13 +47,15 @@ export default {
return {
value1: '',
value2: '值A',
value3: ''
value3: '',
value4: ''
};
},

created() {
this.options1 = ['选项A', '选项B', '选项C'];
this.options3 = ['选项A', '选项B', '选项C'];
this.options4 = ['<i class="indexicon icon-indicator"></i> <- icon 😁', '<i class="indexicon icon-indicator"></i> <- icon 😁', '<i class="indexicon icon-indicator"></i> <- icon 😁'];
this.options2 = [
{
label: '被禁用',
Expand Down
8 changes: 7 additions & 1 deletion packages/radio/src/radio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
:value="option.value || option">
<span class="mint-radio-core"></span>
</span>
<span class="mint-radio-label" v-text="option.label || option"></span>
<span class="mint-radio-label" v-if="renderAsHtml" v-html="option.label || option"></span>
<span class="mint-radio-label" v-else v-text="option.label || option"></span>
</label>
</x-cell>
</div>
Expand All @@ -34,6 +35,7 @@ if (process.env.NODE_ENV === 'component') {
* @param {string} value - 选中值
* @param {string} title - 标题
* @param {string} [align=left] - checkbox 对齐位置,`left`, `right`
* @param {boolean} renderAsHtml - 是否渲染为html
*
* @example
* <mt-radio v-model="value" :options="['a', 'b', 'c']"></mt-radio>
Expand All @@ -48,6 +50,10 @@ export default {
type: Array,
required: true
},
renderAsHtml: {
type: Boolean,
default: false
},
value: String
},

Expand Down