This commit is contained in:
fan
2021-05-15 21:13:50 +08:00
parent 63f8d3ef83
commit d3e296a4ec
11 changed files with 75 additions and 84 deletions
+10 -10
View File
@@ -6,22 +6,22 @@ export default {
src: String,
icon: {
type: String,
default: "lemon-icon-people"
default: "lemon-icon-people",
},
circle: {
type: Boolean,
default() {
return this.IMUI ? this.IMUI.avatarCricle : false;
}
},
},
size: {
type: Number,
default: 32
}
default: 32,
},
},
data() {
return {
imageFinishLoad: true
imageFinishLoad: true,
};
},
render() {
@@ -31,7 +31,7 @@ export default {
class={["lemon-avatar", { "lemon-avatar--circle": this.circle }]}
on-click={e => this.$emit("click", e)}
>
{this.imageFinishLoad && <i class={this.icon} />}
{(this.imageFinishLoad || !this.src) && <i class={this.icon} />}
<img src={this.src} onLoad={this._handleLoad} />
</span>
);
@@ -43,15 +43,15 @@ export default {
width: size,
height: size,
lineHeight: size,
fontSize: `${this.size / 2}px`
fontSize: `${this.size / 2}px`,
};
}
},
},
methods: {
_handleLoad() {
this.imageFinishLoad = false;
}
}
},
},
};
</script>
<style lang="stylus">
+11 -11
View File
@@ -1,4 +1,4 @@
import Vue from "vue";
// import Vue from "vue";
import { isFunction, isEmpty } from "utils/validate";
import LemonPopover from "../components/popover.vue";
let popover;
@@ -64,16 +64,16 @@ export default {
if (isFunction(click)) click(e, component, hidePopover);
});
if (isFunction(render)) {
const ins = Vue.extend({
render: h => {
return render(h, component, hidePopover);
},
});
const renderComponent = new ins().$mount();
node.querySelector("span").innerHTML =
renderComponent.$el.outerHTML;
}
// if (isFunction(render)) {
// const ins = Vue.extend({
// render: h => {
// return render(h, component, hidePopover);
// },
// });
// const renderComponent = new ins().$mount();
// node.querySelector("span").innerHTML =
// renderComponent.$el.outerHTML;
// }
});
showPopover();