完整代码:
<template>
<view>
<view class="all-box">
<image src="@/static/user/near/base.png" class="all-img"></image>
<text class="all-word">元初宇宙银河系太阳系地球亚洲中华人民共和国福建省厦门市同安区</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
onLoad() {
},
methods: {
}
}
</script>
<style lang="scss" scoped>
/*核心思路:通过绝对定位设置图片位置,通过margin设置文本左边距*/
.all-box {
width: 100%;
background-color: #999999;
/*单行省略*/
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
position: relative;
.all-img {
width: 28rpx;
height: 28rpx;
top: 6rpx;
position: absolute;
}
.all-word {
/*文本左边距*/
margin-left: 40rpx;
font-size: 28rpx;
line-height: 40rpx;
color: #333333;
font-weight: 400;
}
}
</style>
Chrome效果: