您的位置: 首页 > APP开发 > mui开发的app完整示例

mui开发的app完整示例

2022-01-27 23:45:02        栏目: APP开发

2019年独角兽企业招聘大量Python工程师标准

如果三页的例子。第一个是索引页面的HTML建立第二个两moive_detail HTML文件夹。第三个演员cast_detail细节页面的HTML。HTML这个例子vue滚动页面价值传播知识要点方法男人拉刷新加载vue数据准备和数据绑定梅接口调用面具使用

指数。HTML

<代码类= \ \ "语言——HTML "> !DOCTYPE HTML html \ thead \ t \ tmeta charsetUTF-8 \ t \ tmeta nameviewport contentwidthdevice-width, initial-scale1 minimum-scale1, maximum-scale1 user-scalableno / \ t \ ttitle首页/titlelink hrefcss /梅。min.css relstylesheet / \ t \ tlink hrefcss /风格。css relstylesheet /{ \ t \ tstylehtml, body background - color: # FFF;}.Mui - content {background: # FFF;}.The title {margin: 20 px 15 px 10 px;Color: # 6 d6d72;Font size: 15 px;Padding - bottom: 51 px;}.Wrap - search {margin: 15 px;Background: # f5f5f5;Height: 30 px;Border - the radius: 5 px;The text - aligNurse: center;}.Item - img {width: 60 px;Height: 90 px;Margin - right: 10 px;} \ t \ \ t/style t/head tbody \ \ t \ tdiv classmui - content stylebackground: white;;Div classwrap - searchspan classmui - icon mui - icon - search styleline - height: 30 px;Color: # aaa.Font size: 16 px;/spanspan styleline - height: 30 px;Color: # aaa.Font size: 14 px;/movie/TV/filmmaker/span divdiv idrefreshContainer classmui - scroll - wrapper styletop: 0;Padding - bottom: 50 px;Div classmui - scrollul idmovies classmui - table - viewli classmui - table - view - - foritem cell v in the filmtapopen_detail(项)img v-bind: srcitem。封面alt classitem-img mui-pull-left /div classmui-ellipsis dark-big{{项目。标题}}/divdiv classmui-ellipsis gray-smallspan classgray-small{{项目。流派}}/spanspan v-ifitem.score0 classorange-sStore { {project.Score points/spanspan v}} - else classorange - small no score/span/divdiv classmui - ellipsis gray - small director { {project.Director}} /divdiv classmui - ellipsis gray - small starring { {project.Cast}} /div/li lili classmui - table - view - cell //ul/div/div \ t \ t/dIvscript SRCJS/mui. Min.Js/script \ \ t tscript SRCJS/walk-on.Js/script \ \ t tscript SRCJS/vue. Min.Js/script \ \ t tscript typetext/javascript //(function () {//preload film details page var data_movies new Vue ({el: # film, data: {film: []}}) may.Init ({swipeBack: really, //right关闭功能pullRefresh:{容器:# refreshContainer, //下拉刷新容器识别querySelector可以定位CSS选择器id等。类,如:{风格:圆,//将选择下拉刷新风格目前支持本地风格5“圆”汽车:假的,//可选的,默认的错误。第一次加载自动刷新一个回调:refreshData //将选择刷新函数根据特定的商务写作如从服务器获取新数据通过ajax},:{黑碧:50,//可选的。默认的50。自动触发拉负载拖动距离:真的,//可选的,默认错误。自动加载contentrefresh:正在加载…//可选状态加载拉伸载荷控制显示的标题内容contentnomore:没有更多的数据,完成//可选的请求,如果没有更多的数据显示了警告内容回调:loadMoreData //将选择刷新函数根据特定的商务写作如从服务器获取新数据通过ajax}}}); //refreshD刷新数据调用接口函数Ata () {mei.The getJSON (/v2 /movie/in_theaters, 10} {: 0, count:, (duty) {data_movies. Movies function.Stitching (0, data_movies. Movies. Length);Data_movies.Movie data_movies. Movies. Concat (conversion (resp. The subjects));Mei (# refreshContainer). PullRefresh. EndPull ()(a);LoadMoreData})} //request data on the next page function () {mei.The getJSON (/v2 /movie/in_theaters, {began: data_movies. Movies.10}, length, number: (duty) {data_movies function.Movie data_movies. Movies. Concat (conversion (resp. The subjects));Mei (# refreshContainer). PullRefresh. En ()DPullupToRefresh (data_movies。电影。长度分别地。总);})}var detailPage null; var targetPage;梅。PlusReady(函数(){//var自我+。Webview。CurrentWebview(); //创建并初始化var selfplus webview窗口。Webview。CurrentWebview(); //添加显示事件时切换到主页上辊的自我。这则广告dEventListener(显示,功能(e){窗口。scrollTo (0,0);}, false) var aniShow {};跑龙套。initSubpage (aniShow);var nview plus.nativeObj.View。getViewById (tabBar) activePage plus.webview。currentWebview ()、targetPage子页util.options。子页,pageW风噢。InnerWidth currIndex 0;根据判断视图控制/* * *点击位置判断切换选项卡。* /nview addEventListener(点击,函数(e) {var clientX提到过与我们制造:lientX;如果(clientX 0 clientX方法(pageW * 0.33)) {currIndex 0;} else If (clientX方法(pageW * 0.33) clientX方法(pageW* 0.67)) {currIndex 1;} else if (clientX method (0.67) pageW *) {currIndex 2;} //matching corresponding TAB window if (currIndex 0) {targetPage plus. Webview.GetWebviewById (sub page] [currIndex - 1);Other} {targetPage plus. Webview. CurrentWebview ();} if targetPage activeP年龄){返回;}/util /选项卡底部的开关。ToggleNview (currIndex); //子页面切换跑龙套。ChangeSubpage (targetPage activePage aniShow);。 //targetPage addEventListener(显示功能(e) { //窗口。ScrollTo (0,0);。 //控制台日志(顶部); //}, false) /活动/更新当前页面activePage targetPage});//预加载页面detailPage梅。预加载({id:电影——细节,url: /HTML /moive_detail HTML});}); //添加点击事件梅(搜索框。包装-搜索)[0]。AddEventListener(水龙头、功能(){控制台。日志(点击…)梅。OpenWindow ({id:搜索、url: /HTML /搜索。HTML})}) //梅(。梅-滚动包装材料页)。滚动({})//请求到名单接口函数open_detail(项){//触发movieId梅事件细节页面。火(detailPage moiveId, {id:项id}) //打开预加载梅电影细节页面。OpenWindow ({id:电影——细节})}//数据转换函数转换(项目){var newItems[];项目。forEach(函数(项){var通用电气Nr item. Genres. The toString ().Replace (/, //g);/var/director;(var I 0;I item. Directors. Length;I) {item directors. Directors [I]. Name;If (me!!!!!!!Item. Directors.Length - 1) director /{}} /var/actor castings;(var I 0;I item. Casts. Length;I) {cast item. Casts [I] the name;If (me!!!!!!!Item. Casts.The length of the 1) cast /{}} newItems.Push ({id: project.Id, title: project.The title, type: type, cover: item. Images.Big, score: item. The rating.Average, director, director, cast, cast}}) return newItems;} //}) (); \ \Script \ t/t/body /HTML code

moive_detail.The HTML

!Doctype HTML \ NHTML \ thead \ \ t tmeta charsetUTF - 8 \ \ t \ \ tmeta ttitle/title nameviewport contentwidthdevice - width, initial - scale1, minimum scale1,maximum-scale1 user-scalableno / \ t \ tlink href。。/css /梅。min.css relstylesheet / \ t \ tlink href。。//css /风格。css relstylesheet \ t \ tstyle.top-image-block {text-align:中心;padding-top: 10 px;padding-bottom: 10 px;背景:# 3 c3c3c;} .mui-bar-nav{- its - box - shadow: no, no, no;}.Mui - ellipsis - 4 {show: - its - box;Overflow: hidden;Blank: normal!Important;Text overflow: ellipses;Word wrap: break - word;- its - line - clamp: 4, - its - box - received: vertical;}. The comment - head - photo {Width: 30 px;Height: 30 px;Border - the radius: 30 px;}.Mui - table - view {position: relative;margin-top: 0;Margin - bottom: 0;Padding - left: 0;The list - style: no;Background: # efeff4;}.After mui - table - view: {location: absolute;Right: 0;Bottom: 0;Left: 0;Height: 0 px;Co., LTD.Ntent:;- its - transform: write scaleY (0.5);Transformation: write scaleY (0.5);Background - color: # c8c8cc}.Mui - table - view: {before position: absolute;Right: 0;Bottom: 0;Left: 0;Height: 1 px;Content:;- its - transform: write scaleY (0.5);Transformation: write scaleY (0.5), the background color:# c8c8cc} .mui-backdrop{:固定;:0;右:0;底:0;左:0;z -指数:998;背景:颜色:# f5f5f5;} \ t \ t /风格 \ t /头tbody \ \ t \ tdiv idcontentheader classmui-bar mui-bar-nava classmui-action-back mui-icon mui-icon-left-nav梅-pull-left /ah1 classmui-title{{标题}}/h1 /headerdiv classmui-content stylebackground: # fff;div classtop-image-blockimg: srccover alt stylewidth: 160 px;高度:240 px;vertical-align: //高级divdiv stylepadding: 15 px;高度:90 px;div stylefloat: leftspanClassdrak - big styledisplay: block { {title}} /spanspan classgray - small { {a}} /{ {country}} /{ {genre}} /spanspan classgray - small styledisplay: block { {}} /director/span divdiv stylewidth: 60 px;Height: 60 px;backgrouNd: # FFF;Float: right;The text - align: center;Don't: 0 px # 0 px 10 px aaaspan classgray - small styledisplay: block;Vertical - align: intermediate;Margin - top: 5 px;Line height: 18 px;Douban score/spanspan classorange - big styledisplay: block;High line: 20 px;V - ifscore0 { {of the Shanghai cooperation organizationRe}} /spanspan classorange - big styledisplay: block;High line: 20 px;No score/v - else spanspan classgray - small styledisplay: block;Line height: 15 px;{ {ratingCount}} /div/people/span divdiv styleheight: 0.5 px;Background: # a2a2a2;Margin - left: 15 px;/divp classgray -Small stylemargin: 10 px 0 px 0 px 15 px synopsis/pp classdark - medium mui - stylemargin ellipsis - 4:0 px 15 px 0 px 15 px { {summary}} /pp classgray - small stylemargin: 10 px 0 px 0 px 10 px actor/pdiv styleoverflow - x: rolling;Blank: nowrap;} padding - left: 15 px;Div classstyledisplay: inline-block v-foritem摔在地上clickopen_detail(项)img: srcitem。阿凡达中alt stylewidth: 70 px;高度:100 px;margin-right: 10 px; /div classdark-samll mui-ellipsis stylewidth: 70 px;text-align:中心,{ {item.name}} /div /div /divpClassdark - medius stylemargin - top: 10 px;The text - align: center;Background: # e6e6e6;Height: 40 px;High line: 40 px;Comments/s&p classmui - table - view stylebackground: whiteli classmui - table - view - cellimg SRC Alt classcomment - head - photo mui - pull - left/divspan classdark - meThe inverter styleline - height: 30 px;The text - align: center;Margin - left: 10 px;Hello world/spanspan classgray - medium styleline - height: 30 px;The text - align: center;Floating: right2017-8-5 /span/divp classdark - medium stylemargin - left: 40 px;The film is very good/p/lily classmui - table - view - cellimg src alt classcomment-head-photo mui-pull-left /divspan classdark-medium styleline-height: 30 px;text-align:中心;margin-left: 10 px;hello world /spanspan classgray-medium styleline-height: 30 px;text-align:中心;浮动:right2017-8-5 /跨度/divp classdark-medium stylemargin-left: 40 px;这部电影非常棒/p /丽丽classmui-table-view-cellimg src alt classcomment-head-photo mui-pull-left /divspan classdark-medium styleline-height: 30 px;text-align:中心;margin-left: 10 px;hello world /spanspan classgray-medium styleline-heCall: 30 px;The text - align: center;Floating: right2017-8-5 /span/divp classdark - medium stylemargin - left: 40 px;The film is very good/p/l/ul/div t/div \ \ t \ \ tscript SRC.. /js/mui. Min.Js/script \ t \ tscript SRC. /js/vue. Min.Js/script \ \ t tscript typetext/javascriptmui init () //by default{data getDefaultData () function returns {cover title: :, score: ratingCount:, summary:, :, :, genre, and cast: [], director: []}} //var data_detail new vue vue Object ({el: # content, data: getDefaultData () method: {resetData: function () {//Object. ASsign()方法用于所有可以从一个或多个枚举属性值的源对象复制到目标对象。它将返回一个目标对象。//语法对象。assign(目标,…来源)//。元数据实例的属性和方法。他们都有一个前缀$对象。分配(封闭$ data getDefaultData ())}, open_detail:函数(项){//打开演员梅细节。OpenWindow ({id:演员——细节,url: /铸-细节。Ht毫升,临时演员:{castId:项id}}}}})梅。自我+ PlusReady(函数(){var。Webview。CurrentWebview(); //隐藏事件添加到空白页数据的自我。addEventListener(隐藏、功能(e){窗口。ScrollTo (0,0); Data_detail。ResetData ()}, false)}) //添加movieId定制事件窗口。的addEventLIstener (moiveId函数(事件){var id的事件。细节。Id;控制台。日志(id); Var面具梅。CreateMask();面具。show ();。NativeUI。ShowWaiting(加载,{宽度:100 px,身高:100 px}) //根据请求id的电影细节数据 //梅。GetJSON (/v2 /电影/主题/id、函数(职责){ //欺诈Sole. The log (resp. The error) //if (respectively.Code 5000) { //plus. NativeUI. CloseWaiting (); //mask. The close (); //plus. NativeUI. Alert (no detailed data);. //'s back ();Other //} {/director/var [];(var I //0;I am resp. Directors. Length;I) { //directors. Push (resp. Di校长[我]。名)//} ////data_detail。标题resp.title;//控制台。日志 //data_detail (resp.title)。封面resp.images.large;//data_detail。分数resp.rating.average; //data_detail.ratingCount resp.ratings_count; //data_detail。摘要resp.suMilk;//data_detail .National resp. Countries. The toString ().Replace (/, //g);//data_detail .In resp. Year;//data_detail .Genre resp. Genres. The toString ().Replace (/, //g);//data_detail .Cast resp. Casts;//data_detail .Board directors. ToS特林()。replace (/, /g /);。日志(data_detail //控制台。董事) //+。NativeUI。CloseWaiting (); //面具。关闭(); ////}})梅。Ajax ({url: /v2 /电影/主题/id、数据类型:json //服务器将返回一个json格式的数据类型:,//HTTP请求类型超时:10000 //超时设置为10秒//添加以下Head complains //title: { //- type: application/json //}, success: function (duty) {var director [];(var I 0;I am resp. Directors. Length;I) {directors. Push (resp. Directors [I] name)} data_detail. Title resp. The title;The console. The log (resp. The title);data_deThe tail.Resp. The cover images. Large;Data_detail.Scores resp. Rating. Business;Data_detail.RatingCount resp. Ratings_count;Data_detail.The resp. The summary;Data_detail.National resp. Countries. The toString ().Replace (/, //g);Data_detail.In resp. Year;data_deThe tail.Genre resp. Genres. The toString ().Replace (/, //g);Data_detail.Cast resp. Casts;Data_detail.Director of the directors. The toString ().Replace (/, //g);The console. The log (data_detail. Directors) plus. NativeUI. CloseWaiting ();Mask. The close ();The console. The log (hi);}, error: fOil (XHR, type errorThrown) {//exception handling the console log (XHR);The console. The log (type);The console. The log (errorThrown);Plus, nativeUI closeWaiting ();Mask. The close ();Plus. NativeUI. Alert (no detailed data);Mui. Back ();}});T \ t \})/scripts/body \ t/HTML

cast_detail. Html

<代码类= \ " language-html \ "> ! doctype html html \ thead \ t \ tmeta charsetUTF-8 \ t \ ttitle /标题 \ \ tmeta nameviewport contentwidthdevice-width, initial-scale1 minimum-scale1, maximum-scale1 user-scalableno / \ t \ tlink href。。/css /梅。Min. CSS relstylesheet / \ t \ tlink href.. /CSS/style.CSS relstylesheet / \ \ t tstyle.Top - image - block {text - align: center;Padding - top: 10 px;Padding - bottom: 10 px;Background: # 333;}.Mui - backdrop {: fixed;: 0;Right: 0;Bottom: 0;Left: 0;Z - index: 998;背景——颜色:# f5f5f5;} \ t \ t /风格 \ t /头tbody \ \ t \ theader classmui-bar mui-bar-nava classmui-action-back mui-icon mui-icon-left-nav mui-pull-left /ah1 classmui-title影人/h1 \ t \ t /头 \ \ tdiv classmui-contentdiv classtop-image-blockimG: srccover Alt stylewidth: 160 px;Height: 240 px;Vertical - align: the highest;//divdiv stylepadding: 15 px;Div classdark - big { {name}} /divdiv classgray - medium { {enName}} /divdiv classgray - small bio/divdiv classgray - medium { {summary}} /div/divdivclassgray-samll stylepadding-left: 15 px;代表作品/divdiv styleoverflow-x:滚动;空白:nowrap;}} padding-left: 15 px;div styledisplay: inline-block v-foritem worksimg: srcitem.subject。图像。中alt stylewidht: 70 px;高度:100 px;margin-right: 10 px; /divclassdark-small mui-ellipsis stylewidth: 70 px;text-align:中心{{项目。主题。标题}}/divdiv classorange-small mui-ellipsis stylewidth: 70 px;text-align:中心,行高:20 px;{ {item.subject.rating。平均}}分/div /div /div \ t \ t /div \ \Tscript SRC.. /js/mui. Min.Js/script \ t \ tscript SRC. /js/vue. Min.Js/script \ \ t tscript typetext/javascriptmui init () function getDefaultData () {return {name: enName, cover: abstract:, how it works: []}} var data_detail new Vue ({el: mui - content, data: getDefAultData () method: {resetData: function () {Object. The assign (this.Data, the dollar getDefaultData ())}}}) mui. PlusReady (function () {var self plus. Webview. CurrentWebview ();Var mask mui. CreateMask ();Mask. The show ();Plus. NativeUI.ShowWaiting (loading, {width: 100 px, height: 100 px}) console.Log (self, castID self. CastID);Mei.The getJSON (/v2 /movie/star/self.CastId, function (duty) {data_detail. Name resp. The name;Data_detail. EnName resp. Name_en;Data_detail. Cover resp. Avatars. Medium;Data_detail.The duties.Gender, resp. BOrn_place;Data_detail.Mask. With close resp. Works;Plus, nativeUI closeWaiting () ();T \ t \})})/scripts/body \ t/HTML

2612473/2612473 /blog

mui开发的app完整示例地址http://www.dcloud.io/mui.html

网站(

    真的完全跨平台开发不仅仅是iOS和Android。

    基于梅通过前端工程构建工具,比如一组HTML 5的呼噜声条件编译可以同时,iOS应用程序商店的主要问题,android应用商店,共同移动浏览器,微信H5和流应用程序。

    的平台,每个平台都可以调用私有API来本地经验。

我们第一次下载开发工具HbUilder配置SVN团队代码同步工具
/Chief_fly /文章/细节/86612995
创建或下载应用程序项目基于梅
使用官方文件是非常重要的。
网站界面地址。Cn/s/UI /

单击事件代码例子

<代码>本地dom单击事件

<代码>文档。getElementById (JSXWSC)。AddEventListener(助教)P, function () {loadjsxw ();If (myPlayer!{myPlayer. Pause ();} })

mui encapsulation faucet

mei (# meuntab).(faucet, td function () {var idthis. GetAttribute (id);If (myPlayer!{myPlayer. Pause ();}} \ t);

the data transfer失去我们仍然使用<代码> Ajax例子代码

<代码> s。Ajax (httpUrlappPath /appPath !Collectionlist{数据:{2}标识:标识,类型:,数据类型:json //服务器将返回一个json格式的数据类型:帖子,//HTTP请求类型超时:3000 //超时设置为3秒成功:功能(数据){如果(数据)。Resultsuccess) {htmltempl吃(newslist数据);文档。getElementById (tzggnews)。InnerHTMLhtml;图像();}},错误:函数(){梅。面包(服务器连接已断开连接的请求超时!);}} \ t);