封装好的Header @Component export struct Header{ private title: ResourceStr =''; build(){ Row(){ Image($r('app.media.back')) .width(30) Blank() Text(this.title) .fontSize(30) .fontWeight(FontWeight.Bold) Blank() Image($r('app.media.ref')) .width(30) }.padding({left:20}) .width('90%') .height(30) } }
使用方法在使用的目标ets中
import {Header} from '../components/CommonComponents'
这个只是个例子.