HarmonyOS入门开发(二) Toast使用

众所周知Android中Toast使用很简单

Toast.makeText(this, "msg", Toast.LENGTH_SHORT).show();

那么迁移到HarmonyOS如何使用

//导入toast包
import promptAction from '@ohos.promptAction'

//具体使用
promptAction.showToast({
    message:"测试"
})

//还可传入显示时长
promptAction.showToast({
    message:"测试",
    duration:2000
})

你可能感兴趣的:(HarmonyOS,鸿蒙)