调整自定义插件、代码风格化
parent
cfcc0aa6dd
commit
9e69f6e6c2
@ -0,0 +1,54 @@
|
|||||||
|
<template>
|
||||||
|
<view class="u-text-price-wrap">
|
||||||
|
<text v-for="(item, index) in textArray" :key="index" :style="{ 'font-size': (index === 1 ? integerSize : size) + 'px', 'color': color }">
|
||||||
|
{{ item }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* 此组件存在只为简单的显示特定样式的(人名币)价格数字
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
name: 'custom-text-price',
|
||||||
|
components: {},
|
||||||
|
props: {
|
||||||
|
price: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: '0.00'
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
type: String,
|
||||||
|
default: '#333333'
|
||||||
|
},
|
||||||
|
//字体大小
|
||||||
|
size: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: 15
|
||||||
|
},
|
||||||
|
//整形部分字体大小可单独定义
|
||||||
|
intSize: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
textArray() {
|
||||||
|
let array = ['¥']
|
||||||
|
if (!/^\d+(\.\d+)?$/.test(this.price)) {
|
||||||
|
console.error('组件<custom-text-price :text="???" 此处参数应为金额数字')
|
||||||
|
} else {
|
||||||
|
let arr = parseFloat(this.price).toFixed(2).split('.')
|
||||||
|
array.push(arr[0])
|
||||||
|
array.push('.' + arr[1])
|
||||||
|
}
|
||||||
|
return array
|
||||||
|
},
|
||||||
|
integerSize() {
|
||||||
|
return this.intSize ? this.intSize : this.size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style></style>
|
||||||
@ -1,24 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container"> </view>
|
||||||
|
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
title: ''
|
title: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {},
|
||||||
|
methods: {}
|
||||||
},
|
}
|
||||||
methods: {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped></style>
|
||||||
</style>
|
|
||||||
|
|||||||
@ -1,24 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container"> 个人资料 </view>
|
||||||
个人资料
|
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
title: ''
|
title: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {},
|
||||||
|
methods: {}
|
||||||
},
|
}
|
||||||
methods: {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped></style>
|
||||||
</style>
|
|
||||||
|
|||||||
@ -1,60 +0,0 @@
|
|||||||
<template>
|
|
||||||
<view class="u-text-price-wrap">
|
|
||||||
<text
|
|
||||||
v-for="(item,index) in textArray"
|
|
||||||
:key="index"
|
|
||||||
:style="{'font-size': (index === 1 ? integerSize : size) + 'px', 'color': color}"
|
|
||||||
>
|
|
||||||
{{item}}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
/**
|
|
||||||
* 此组件存在只为简单的显示特定样式的(人名币)价格数字
|
|
||||||
*/
|
|
||||||
export default {
|
|
||||||
name: "u--text-price",
|
|
||||||
components: {
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
text: {
|
|
||||||
type: String,
|
|
||||||
default: '0.00'
|
|
||||||
},
|
|
||||||
color: {
|
|
||||||
type: String,
|
|
||||||
default: '#333333'
|
|
||||||
},
|
|
||||||
//字体大小
|
|
||||||
size: {
|
|
||||||
type: [String, Number],
|
|
||||||
default: uni.$u.props.text.size
|
|
||||||
},
|
|
||||||
//整形部分字体大小可单独定义
|
|
||||||
intSize: {
|
|
||||||
type: [String, Number],
|
|
||||||
default: uni.$u.props.text.size
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
textArray() {
|
|
||||||
let array = ['¥'];
|
|
||||||
if (!/^\d+(\.\d+)?$/.test(this.text)) {
|
|
||||||
uni.$u.error('组件<u--text-price :text="???" 此处参数应为金额数字');
|
|
||||||
} else {
|
|
||||||
let arr = parseFloat(this.text).toFixed(2).split('.');
|
|
||||||
array.push(arr[0]);
|
|
||||||
array.push('.' + arr[1]);
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
},
|
|
||||||
integerSize() {
|
|
||||||
return this.intSize ? this.intSize : this.size
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<style>
|
|
||||||
</style>
|
|
||||||
Loading…
Reference in New Issue