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

在dw上做网站首页导航栏四平网络推广

在dw上做网站首页导航栏,四平网络推广,wordpress slug translate,jsp做的网站怎嘛用背景 为了解决uni-app 任意位置出现弹窗 解决方案 一、最初方案 受限于uni-app 调用组件需要每个页面都引入注册才可以使用,此方案繁琐,每个页面都要写侵入性比较强 二、改进方案 app端:新建一个页面进行跳转,可以实现伪弹窗…

背景

为了解决uni-app 任意位置出现弹窗

解决方案

一、最初方案

受限于uni-app 调用组件需要每个页面都引入注册才可以使用,此方案繁琐,每个页面都要写侵入性比较强

二、改进方案

app端:新建一个页面进行跳转,可以实现伪弹窗(其实是打开一个背景透明的页面)

web端: 全局挂载body 插入一个弹窗

三、初步实现方案

就是 利用条件编译,web端写组件、app 端写页面,利用不同的生命周期,完成通用的逻辑

四、详细实现方案

1、完成弹窗页面开发

统一暴露一个show 方法,app 端使用 onload 监听事件触发,web端使用 show 方法触发

    <template><u-popup id="globalPopup-box" :show="params.show" :mode="params.mode" bgColor="transparent"@close="cancelSubmit(true)"><template v-if="params.type === 1"><view class="globalPopupContent" :class="{ globalPopupContentCenter: params.mode == 'center' }"><view class="title">{{ params.title }}</view></view></template><template v-else><view class="globalPopupContent" :class="{ globalPopupContentCenter: params.mode == 'center' }"><view class="title">{{ params.title }}</view></view></template></u-popup>
</template><script>
export default {name: "globalPopup",data() {return {eventChannel: null,params: {},}},// #ifdef APP-PLUSonLoad() {this.eventChannel = this.getOpenerEventChannel();this.eventChannel.on('globalPopup', (data) => {console.log('globalPopup:', data)this.init(data)})},// #endifmethods: {init(data) {this.params = data// 通用逻辑写在这里},// #ifdef H5show(data) {console.log('H5globalPopup:', data)this.init(data)},// #endifcancel() {// #ifdef APP-PLUSlet _this = this;uni.navigateBack({delta: 1,success() {_this.eventChannel.emit('cancel');}})// #endifthis.hide()// #ifdef APP-PLUSthis.params.cancel && this.params.cancel();// #endif},confirm() {// #ifdef APP-PLUSlet _this = this;uni.navigateBack({delta: 1,success() {_this.eventChannel.emit('confirm');}})// #endifthis.hide();// #ifdef APP-PLUSthis.params.confirm && this.params.confirm();// #endif},hide() {setTimeout(() => {this.params = {}}, 100)}}
}
</script><style>
page {background: transparent;
}
</style>

2、页面路由配置

,{"path" : "components/globalPopup/globalPopup","style": {"navigationStyle": "custom","backgroundColor": "transparent","app-plus": {"animationType": "fade-in","background": "transparent","popGesture": "none","bounce": "none","titleNView": false}}},          

3、main.js中全局挂载 globalPopup.js

globalPopup.js

const install = Vue => {Vue.prototype.$globalPopup = {show(params) {let pointPageUrl = getCurrentPages()[getCurrentPages().length - 1].route;if (pointPageUrl == 'components/globalPopup/globalPopup') returnuni.navigateTo({url: '/components/globalPopup/globalPopup',success: function (res) {// 利用事件 通知 目标页面res.eventChannel.emit('globalPopup', params)}})}}
}
export default install;

main.js 的编码 条件编译

// #ifdef APP-PLUS
import globalPopupjs from '@/components/globalPopup/globalPopup.js';
Vue.use(globalPopupjs);
// #endif// #ifdef H5
import globalPopup from '@/components/globalPopup/globalPopup.vue'
const PopupVue = Vue.extend(globalPopup);
const popupDom = new PopupVue();
Vue.prototype.$globalPopup = popupDom.$mount();
const lastEl = document.body.lastElementChild;
if (lastEl.id !== 'globalPopup-box') {setTimeout(() => {document.body.appendChild(Vue.prototype.$globalPopup.$el)}, 0)
}
// #endif

4、如何任意位置出现弹窗

利用接口触发,返回相关弹窗配置

接口触发逻辑

if (data.pop) {uni.$emit('showMyPopup', data.pop)}

监听逻辑

// 监听事件uni.$on('showMyPopup', (pop) => {if (!this.isShowGlobalPopup) {console.log(pop, 'showMyPopup')let {userQuestionStyleValue, // 样式值 1底部弹窗 2页中弹窗userQuestionTemplateValue, // 模板值 1是否类 2打分类,userQuestionInfo,userQuestionAnswerDTO,} = popthis.$globalPopup.show({id: pop.id,show: true,type: userQuestionTemplateValue == '1' ? 1 : 2,userQuestionInfo,title: userQuestionInfo.questionName,userQuestionAnswerDTO,mode: userQuestionStyleValue == '1' ? 'bottom' : 'center'})}});

效果

http://www.tj-hxxt.cn/news/77381.html

相关文章:

  • 营销型网站备案东莞网站推广及优化
  • macbook air做网站关键词排名网络推广
  • python 做网站 数据库搜索网站
  • 吉林省建设厅信息网站网站搜索关键词优化
  • 上海做网站站长之家域名解析
  • 网站开发费用无形资产网站seo在线优化
  • 注册域名需要多久对搜索引擎优化的认识
  • 苏州做网站价格软文推广是什么
  • 西乡专业建站免费推广公司
  • 商城类网站如何做seo上海seo优化公司bwyseo
  • 手机页面网站开发例子百度竞价排名什么意思
  • 源代码网站和模板做的区别企业营销案例
  • 怎么做自己微信的网站百度高级搜索
  • 淘宝客网站一定要备案软件开发公司经营范围
  • 合肥哪家公司做网站靠谱新公司如何做推广
  • 滨海网站建设找哪家好seo培训班
  • 网站建设方案意见电子商务推广方式
  • 静态网站开发工具有哪些上海网站快速排名优化
  • archdailyseo优化排名方法
  • ps做图游戏下载网站有哪些优化大师好用吗
  • 专做教育网站拿站营销活动方案模板
  • 西安做的好的网站公司新闻源
  • 8个页面的网站怎么做在线制作网站免费
  • 成都市建设交通委员会网站网页推广平台
  • 香港公司网站内地主机桔子seo查询
  • 帮人做网站的推广一键优化下载
  • 中国纪检监察报谁题的报名北京网优化seo公司
  • 商城类网站建设需要多少钱谷歌搜索引擎入口2021
  • 门户网站收录什么叫做优化
  • 小视频网站开发流程图北京疫情最新情况