Utils 工具库 - Util 常用工具函数

去除空格

#trim

  • 字符串的空格截取
<template>
    <div class="wrapper">
        <text>trim: 去除字符串空格</text>
    </div>
</template>
<script>
export default {
    data:()=> ({
        name: 'trim',
        str: '    hello, dolphinWeex !   '
    }),
    methods: {
        trimHandler() {
            let { str } = this
            //去除空格
            let res = this.$util.trim(str)
            this.$toast(res)
        }
    }
}
</script>
<style scoped>
.wrapper{
    background-color: #ffffff;
}
</style>

#参数

  • 成功时返回
Params Type Required default Value
str String Y - 传入的字符串
pos String N both `both
posted on 2024-12-13 09:20  AtlasLapetos  阅读(12)  评论(0)    收藏  举报