赞
踩
src/main/ets/MainAbility/components/compTest.ets
@Entry
@Component
export struct compTest{
@State one:string = "Test"
build(){
Column(){
Text(this.one).fontSize(25).fontColor("#f0f")
}
}
}
src/main/ets/MainAbility/pages/index.ets
import { compTest } from '../components/compTest'; //引入
import router from '@system.router'
import featureAbility from '@ohos.ability.featureAbility';
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
compTest()//调用
}
.width('100%')
}
.height('100%')
}
}
src/main/ets/MainAbility/components/compTest.ets
@Entry
@Component
export struct compTest{
@State one:string = "Test"
build(){
Column(){
Text(this.one).fontSize(25).fontColor("#f0f")
}
}
}
@Component
export struct compTest01{
@State two:string = "Test01"
build(){
Column(){
Text(this.two).fontSize(30).fontColor("#f00")
}
}
}
src/main/ets/MainAbility/pages/index.ets
import { compTest,compTest01 } from '../components/compTest';
import router from '@system.router'
import featureAbility from '@ohos.ability.featureAbility';
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
compTest()
compTest01()
}
.width('100%')
}
.height('100%')
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。