文章内容
效果图

代码
import QtQuick 2.15
import QtQuick.Window 2.15
import FluentUI
import QtQuick.Controls 2.5Window {visible: truewidth: 320height: 240Component{id:comRectangle{id:rectwidth: 80height: 60color: "red"Component.onCompleted: { console.log("调用")}Component.onDestruction: { console.log("析构")}}}Loader{id:loadersourceComponent: com onStatusChanged: {console.log("status:",status)}}Button{id: button1width: 100height: 40x:100text:"动态加载按钮"onClicked: {loader.item.width = 40loader.item.color = "blue"}}Button{width: 100height: 40anchors.left: button1.leftanchors.top:button1.bottomtext:"析构按钮"onClicked: {loader.sourceComponent = null}}
}