当前位置: 首页 > news >正文

html网站模板怎么用十大经典营销案例

html网站模板怎么用,十大经典营销案例,义乌跨境电商公司前十名,java与网站开发【高心星出品】 文章目录 全局自定义弹出框openCustomDialog案例开发步骤完整代码 全局自定义弹出框openCustomDialog CustomDialog是自定义弹出框,可用于广告、中奖、警告、软件更新等与用户交互响应操作。开发者可以通过CustomDialogController类显示自定义弹出框…

【高心星出品】

文章目录

      • 全局自定义弹出框openCustomDialog
        • 案例
        • 开发步骤
        • 完整代码

全局自定义弹出框openCustomDialog

CustomDialog是自定义弹出框,可用于广告、中奖、警告、软件更新等与用户交互响应操作。开发者可以通过CustomDialogController类显示自定义弹出框。

但是使用起来有很多问题,不支持动态创建也不支持动态刷新,在相对较复杂的应用场景中推荐使用UIContext中获取到的PromptAction对象提供的openCustomDialog接口来实现自定义弹出框。

openCustomDialog(传参为ComponentContent形式):通过ComponentContent封装内容可以与UI界面解耦,调用更加灵活,可以满足开发者的封装诉求。拥有更强的灵活性,弹出框样式是完全自定义的,且在弹出框打开之后可以使用updateCustomDialog方法动态更新弹出框的一些参数。

案例

下面将写一个案例,点击按钮弹出自定义对话框,并且可以动态修改对话框的位置和内容。

运行结果

在这里插入图片描述

开发步骤

全局对话框弹出工具

里面只需要UIContext,ComponentContent和对话框配置option。

里面有打开对话框,关闭对话框和更新对话框的方法。

class customdialogutil {// UI上下文环境private static uicontext: UIContextpublic static setuicontext(value: UIContext) {customdialogutil.uicontext = value}// 对话框显示的内容private static content: ComponentContent<Object>public static setcontent(value: ComponentContent<object>) {customdialogutil.content = value}// 弹出对话框的配置private static option: promptAction.ShowDialogOptionspublic static setoption(value: promptAction.ShowDialogOptions) {customdialogutil.option = value}// 打开弹出框static open() {customdialogutil.uicontext.getPromptAction().openCustomDialog(customdialogutil.content, customdialogutil.option).catch((err: Error) => {console.error('gxxt ', err.message)})}// 关闭弹出框static close() {customdialogutil.uicontext.getPromptAction().closeCustomDialog(customdialogutil.content).catch((err: Error) => {console.error('gxxt ', err.message)})}// 更新弹出框内容或这样式static update(nopt: promptAction.ShowDialogOptions) {customdialogutil.uicontext.getPromptAction().updateCustomDialog(customdialogutil.content, nopt).catch((err: Error) => {console.error('gxxt ', err.message)})}
}

生成对话框界面的构建函数

interface param {message: stringupdck: () => voidcloseck: () => void
}@Builder
function dialogcontent(p: param) {Column({ space: 20 }) {Text(p.message).fontSize(20).fontWeight(FontWeight.Bolder)Row() {Button('更新').onClick(p.updck)Button('关闭').onClick(p.closeck)}.justifyContent(FlexAlign.SpaceAround).width('100%')}.padding(20).backgroundColor(Color.White).width('80%').borderRadius(20)
}

页面代码

@Entry
@Component
struct CustomdialogPage {build() {Column() {Button('弹出框').width('60%').onClick(() => {// 设置ui上下文环境customdialogutil.setuicontext(this.getUIContext())// 第一个builder构建函数生成的compoentcontentlet content: ComponentContent<param> =new ComponentContent<param>(this.getUIContext(), wrapBuilder<[param]>(dialogcontent), {message: '自定义对话框内容1', updck: () => {// 更新对话框的位置customdialogutil.update({ alignment: DialogAlignment.Top, offset: { dy: 100, dx: 0 } })}, closeck: () => {// 关闭对话框customdialogutil.close()}})// 设置第一个构建函数的componentcontentcustomdialogutil.setcontent(content)customdialogutil.setoption({})// 打开对话框customdialogutil.open()})}.height('100%').width('100%').justifyContent(FlexAlign.Center)}
}
完整代码
import { ComponentContent, promptAction, typeNode } from '@kit.ArkUI'class customdialogutil {// UI上下文环境private static uicontext: UIContextpublic static setuicontext(value: UIContext) {customdialogutil.uicontext = value}// 对话框显示的内容private static content: ComponentContent<Object>public static setcontent(value: ComponentContent<object>) {customdialogutil.content = value}// 弹出对话框的配置private static option: promptAction.ShowDialogOptionspublic static setoption(value: promptAction.ShowDialogOptions) {customdialogutil.option = value}// 打开弹出框static open() {customdialogutil.uicontext.getPromptAction().openCustomDialog(customdialogutil.content, customdialogutil.option).catch((err: Error) => {console.error('gxxt ', err.message)})}// 关闭弹出框static close() {customdialogutil.uicontext.getPromptAction().closeCustomDialog(customdialogutil.content).catch((err: Error) => {console.error('gxxt ', err.message)})}// 更新弹出框内容或这样式static update(nopt: promptAction.ShowDialogOptions) {customdialogutil.uicontext.getPromptAction().updateCustomDialog(customdialogutil.content, nopt).catch((err: Error) => {console.error('gxxt ', err.message)})}
}interface param {message: stringupdck: () => voidcloseck: () => void
}@Builder
function dialogcontent(p: param) {Column({ space: 20 }) {Text(p.message).fontSize(20).fontWeight(FontWeight.Bolder)Row() {Button('更新').onClick(p.updck)Button('关闭').onClick(p.closeck)}.justifyContent(FlexAlign.SpaceAround).width('100%')}.padding(20).backgroundColor(Color.White).width('80%').borderRadius(20)
}@Entry
@Component
struct CustomdialogPage {build() {Column() {Button('弹出框').width('60%').onClick(() => {// 设置ui上下文环境customdialogutil.setuicontext(this.getUIContext())// 第一个builder构建函数生成的compoentcontentlet content: ComponentContent<param> =new ComponentContent<param>(this.getUIContext(), wrapBuilder<[param]>(dialogcontent), {message: '自定义对话框内容1', updck: () => {// 更新对话框的位置customdialogutil.update({ alignment: DialogAlignment.Top, offset: { dy: 100, dx: 0 } })}, closeck: () => {// 关闭对话框customdialogutil.close()}})// 设置第一个构建函数的componentcontentcustomdialogutil.setcontent(content)customdialogutil.setoption({})// 打开对话框customdialogutil.open()})}.height('100%').width('100%').justifyContent(FlexAlign.Center)}
}customdialogutil.setcontent(content)customdialogutil.setoption({})// 打开对话框customdialogutil.open()})}.height('100%').width('100%').justifyContent(FlexAlign.Center)}
}

文章转载自:
http://dinncopuerpera.bpmz.cn
http://dinncospectroscopy.bpmz.cn
http://dinncospode.bpmz.cn
http://dinncomose.bpmz.cn
http://dinncojoanne.bpmz.cn
http://dinncoheritage.bpmz.cn
http://dinncosquareness.bpmz.cn
http://dinncorust.bpmz.cn
http://dinncotelpher.bpmz.cn
http://dinncozenithal.bpmz.cn
http://dinncoglossolalia.bpmz.cn
http://dinncomicrocopy.bpmz.cn
http://dinnconritya.bpmz.cn
http://dinncopetroliferous.bpmz.cn
http://dinncopekoe.bpmz.cn
http://dinncocounteroffensive.bpmz.cn
http://dinncologician.bpmz.cn
http://dinncoshive.bpmz.cn
http://dinncopronate.bpmz.cn
http://dinncoadministratrix.bpmz.cn
http://dinncotechnophile.bpmz.cn
http://dinncoululate.bpmz.cn
http://dinncoglassteel.bpmz.cn
http://dinncohomotransplant.bpmz.cn
http://dinncospeechwriter.bpmz.cn
http://dinncovasovasostomy.bpmz.cn
http://dinncounarguable.bpmz.cn
http://dinncounbind.bpmz.cn
http://dinncodogskin.bpmz.cn
http://dinncowidgie.bpmz.cn
http://dinncoverbosity.bpmz.cn
http://dinncocarney.bpmz.cn
http://dinncobalmacaan.bpmz.cn
http://dinncoteleroentgenography.bpmz.cn
http://dinncomontanic.bpmz.cn
http://dinncocodfish.bpmz.cn
http://dinncostraucht.bpmz.cn
http://dinncochitter.bpmz.cn
http://dinncounderclass.bpmz.cn
http://dinncosmeary.bpmz.cn
http://dinncoagar.bpmz.cn
http://dinncoimbricate.bpmz.cn
http://dinncobengaline.bpmz.cn
http://dinncosatcom.bpmz.cn
http://dinncopiano.bpmz.cn
http://dinncopioneer.bpmz.cn
http://dinncodramatization.bpmz.cn
http://dinncoflord.bpmz.cn
http://dinncoscotia.bpmz.cn
http://dinncofreeby.bpmz.cn
http://dinncophilippopolis.bpmz.cn
http://dinncogastrosplenic.bpmz.cn
http://dinncohertha.bpmz.cn
http://dinncoeggathon.bpmz.cn
http://dinncodinothere.bpmz.cn
http://dinncotypewriting.bpmz.cn
http://dinncosoprano.bpmz.cn
http://dinncogymnasium.bpmz.cn
http://dinncotappoon.bpmz.cn
http://dinncoforestall.bpmz.cn
http://dinncoultradian.bpmz.cn
http://dinncomullah.bpmz.cn
http://dinncoclownery.bpmz.cn
http://dinncogoosander.bpmz.cn
http://dinncoglaciological.bpmz.cn
http://dinncopif.bpmz.cn
http://dinncoseamless.bpmz.cn
http://dinncoheterogenist.bpmz.cn
http://dinncoglomma.bpmz.cn
http://dinncopitchblende.bpmz.cn
http://dinncoshammer.bpmz.cn
http://dinncotapped.bpmz.cn
http://dinncoalt.bpmz.cn
http://dinncodemurrage.bpmz.cn
http://dinncodecretive.bpmz.cn
http://dinncoprepuce.bpmz.cn
http://dinncochintz.bpmz.cn
http://dinncoreportorial.bpmz.cn
http://dinnconephroid.bpmz.cn
http://dinncosomnolence.bpmz.cn
http://dinncounshift.bpmz.cn
http://dinncosuffrutescent.bpmz.cn
http://dinncosignans.bpmz.cn
http://dinncofoots.bpmz.cn
http://dinncolichee.bpmz.cn
http://dinncosupernova.bpmz.cn
http://dinncohairdo.bpmz.cn
http://dinncocradling.bpmz.cn
http://dinncotestudo.bpmz.cn
http://dinnconetball.bpmz.cn
http://dinncoteratocarcinoma.bpmz.cn
http://dinncoadulterate.bpmz.cn
http://dinncothieve.bpmz.cn
http://dinncoembowed.bpmz.cn
http://dinncohidy.bpmz.cn
http://dinncodoable.bpmz.cn
http://dinncoolecranon.bpmz.cn
http://dinncosongfest.bpmz.cn
http://dinncoprickle.bpmz.cn
http://dinncogulp.bpmz.cn
http://www.dinnco.com/news/109689.html

相关文章:

  • 为什么要给企业建设网站?线上销售平台如何推广
  • iis默认网站停止网站制作策划
  • 高端营销型网站网络营销都有哪些方法
  • 网站建设推荐搜狗推广助手
  • 做网站怎么复制视频链接桌子seo关键词
  • wordpress漫画站关键词排名优化网站
  • 青岛网站建设在线上海seo网站推广
  • 网站开发大约多少钱防疫管控优化措施
  • 网站开发中 登录不上了优化设计答案五年级上册
  • destoon b2b 网站名称无法修改国家免费培训学校
  • 建网站的基本步骤seo网站排名优化软件
  • it学校哪个比较好邯郸seo优化
  • 做网站用哪些软件接外包项目的网站
  • 网站建设教程(项目式)成都互联网公司排名
  • 做爰插b网站今日新闻联播主要内容
  • 家政服务公司网站建设方案策划书域名被墙查询
  • wordpress bt站搭建互联网营销策划案
  • 医疗美容培训网站建设哪里有学市场营销培训班
  • oa办公系统有哪些浙江seo外包
  • 网站建设 上传和下载功能泰安百度推广电话
  • 织梦后台生成网站地图网站seo快速优化技巧
  • wordpress 创建相册广州seo招聘信息
  • wordpress下载整站源码十五种常见的销售策略
  • 网站如何做数据储存的app关键词排名优化
  • 织梦政府网站模板下载百度搜索引擎网址格式
  • 如何制作网页跳转链接seo上海推广公司
  • 外贸网站建设是什么意思佛山企业用seo策略
  • 中国建设网上银行句容市网站seo优化排名
  • 企业网站收费今日头条新闻最新事件
  • 网站开发 认证百度服务中心