Vue2.7以前
<Upload
ref="upload"
:show-upload-list="false"
:before-upload="handleBeforeUpload"
:disabled="disabled"
:max-size="maxSize"
action
>
.info-img-wrap {
--textAlignPosition: center;
/deep/ .ivu-upload {
text-align: var(--textAlignPosition);
}
}
- js 通过setProperty()方法修改“--textAlignPosition”的值,从而间接改变对应子元素的(text-align)
mounted() {
this.$nextTick(function () {
this.$refs.upload.$el.style.setProperty(
'--textAlignPosition',
this.textAlign
);
});
}
Vue2.7以后
<template>
<span> 有开始循环了-开端 </span>
</template>
<script setup>
import { reactive } from 'vue'
const state = reactive({
color: 'red'
})
</script>
<style scoped>
span {
color: v-bind('state.color');
}
</style>