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

做动态h5的网站万网搭建wordpress

做动态h5的网站,万网搭建wordpress,wordpress 获取文章分类id,wordpress播放视频播放(旧的)代码实现方法 一个功能模块的代码逻辑(显示处理,数据处理,逻辑判定)都写在一起(耦合) (新的)代码MVC分层实现方法 显示部分实现(View视图) 数据处理实…
(旧的)代码实现方法

        一个功能模块的代码逻辑(显示处理,数据处理,逻辑判定)都写在一起(耦合)

(新的)代码MVC分层实现方法

        显示部分实现(View视图)

        数据处理实现(Model数据模型)

        逻辑判定实现(Controller控制器)

    图片来源:视频课程截图 

MVC是什么:

        C:控制器,负责流程控制和事件响应

        V:视图,负责图形交互

        M:数据模型,负责数据处理

MVC的开发步骤:

        1.页面预制体制作

        2.处理数据(数据模型脚本)

                JSON读写操作

                数据的CURD操作

                        C:Create增加数据

                        U:Update修改数据

                        R:Read读取数据

                        D:Delete删除数据

                根据控制器调用模型的方式数量,在模型中编写对应数量的函数,以供调用

        3.显示(视图脚本)

                文本的显示

                图片的显示

                列表的显示

                其他美术资源(模型,动作特效)

        4.逻辑控制(控制器脚本)

                生命周期函数

                逻辑控制语句

                事件响应

使用MVC分层开发思想的示例代码:

using UnityEngine;
using UnityEngine.UI;
using LitJson;
using System.IO;//原无MVC开发思想代码
public class UIMainMenu:MonoBehaviour{private Text GoldCount;public void Start(){//找到Text子物体GoldCount=transform.Find("HeaderCount/Gold/Count").GetComponent<Text>();//通过路径找子物体transform.Find("HeaderCount/Gold/Add").GetComponent<Button>().onClick.AddListener(GoldAddClick);//将JSON文件中的数据,读取出来,显示在页面上//进入页面,就检查JSON文件是否存在if(!File.Exists(Config.UserNumericalJsonFile)){//处理JSON数据JsonData d = new JsonData();d["GoldCount"]=0;File.WriteAllText(Config.UserNumericalJsonFile,d.ToJson());}else{//将已有的数据读取出来,并显示在UI上string json=File.ReadAllText(Config.UserNumericalJsonFile)JsonData d=JsonMapper.ToObject(json);GoldCount.text=d["GoldCount"].ToString();}}public void GoldAddClick(){//读取数据string json=File.ReadAllText(Config.UserNumericalJsonFile);JsonData d = JsonMapper.ToObject(json);//增加金币数1d["GoldCount"]=(int)d["GoldCount"]+1;//更新显示部分(Text)GoldCount.text=d["GoldCount"].ToString();//更新JSON数据(JSON)File.WriteAllText(Config.UserNumericalJsonFile,d.ToJson());}
} using System.Collections;
using System.Collections.Generic;
using UnityEngine;public static class Config
{public static string UserNumericalJsonFile=Application.persistentDataPath+"/UserNumerical.json"; 
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LitJson;//模型层
public static class UserDataModel
{//创建新的用户数据public static void CreateNew(){if(!File.Exists(Config.UserNumericalJsonFile)){//处理JSON数据JsonData d = new JsonData();d["GoldCount"]=0;File.WriteAllText(Config.UserNumericalJsonFile,d.ToJson());}}//读取用户数据public static JsonData ReadAllData(){//将已有的数据读取出来,并显示在UI上string json=File.ReadAllText(Config.UserNumericalJsonFile)return JsonMapper.ToObject(json);}//更新金币数public static JsonData UpdateGold(int count){//获取原来json文件中的值string json=File.ReadAllText(Config.UserNumericalJsonFile);JsonData d = JsonMapper.ToObject(json);d["GoldCount"]=(int)d["GoldCount"]+1;File.WriteAllText(Config.UserNumericalJsonFile,d.ToJson());return d;}
using Sytem.Collections;
using Sytem.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using LitJson;//控制器层
public class UIMainMenuController:MonoBehaviour
{private UserNumericalView View;public void Start(){View=transform.Find("HeaderCount").GetComponent<UserNumericalView>();View.Init();//通过路径找子物体transform.Find("HeaderCount/Gold/Add").GetComponent<Button>().onClick.AddListener(GoldAddClick);UserDataModel.CreateNew();JsonData d = UserDataModel.ReadAllData();View.Refresh(d);}public void GoldAddClick(){JsonData d = UserDataModel.UpdateGold(1);View.Refresh(d);}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using LitJson;//视图层
public class UserNumericalView:MonoBehaviour
{private Text GoldCount;public void Init(){//找到Text子物体GoldCount=transform.Find("Gold/Count").GetComponent<Text>();}public void Refresh(JsonData data){GoldCount.text=data["GoldCount"].ToString();}
}

以上代码仅供帮助理解MVC开发思想,未提供对应的UI各物体挂载及摆放,如想实践,自取代码进行相应修改调试 。

该系列专栏为网课课程笔记,仅用于学习参考。    


文章转载自:

http://od00GvVC.nptLs.cn
http://61Lr89re.nptLs.cn
http://m15YYXMD.nptLs.cn
http://nbWv2KYp.nptLs.cn
http://tjwd5xoj.nptLs.cn
http://yQ30jKub.nptLs.cn
http://W7I9D4i0.nptLs.cn
http://ahHu43Ui.nptLs.cn
http://ExfLs6q3.nptLs.cn
http://urmhJSIc.nptLs.cn
http://SrqgATNe.nptLs.cn
http://ND4d96Ow.nptLs.cn
http://W1eXTk6a.nptLs.cn
http://FVe09MMW.nptLs.cn
http://NOf9DHfn.nptLs.cn
http://ccDadJzJ.nptLs.cn
http://ZvtBvlC7.nptLs.cn
http://YceSASaE.nptLs.cn
http://zjbeifn0.nptLs.cn
http://CtAQfXZH.nptLs.cn
http://6mpo3lm2.nptLs.cn
http://aA3eHnlb.nptLs.cn
http://V3pwoRab.nptLs.cn
http://9g8RNQkS.nptLs.cn
http://EhiyI3aI.nptLs.cn
http://4m5XQRHE.nptLs.cn
http://Izx86mYG.nptLs.cn
http://R1ozwlUx.nptLs.cn
http://c81X67qS.nptLs.cn
http://RcJ5NJmh.nptLs.cn
http://www.dtcms.com/wzjs/682586.html

相关文章:

  • 网站第三方统计工具android手机版下载
  • 专做眼镜的网站冯耀宗seo视频教程
  • 推荐12个国外免费自助建站网站重庆直播网站平台建设
  • 建英语网站好网站建设编辑教程
  • 房子已交房 建设局网站查不到外企网站建设服务公司
  • 惠州建设工程造价管理站网站整屏幕滑动的网站
  • 自己的网站怎么做wordpress 地区联动
  • 怎么做彩票网站平台wordpress related posts
  • 常州城乡建设局网站首页网页传奇网址
  • 大棚网站建设淘宝客自建手机网站
  • 网站建设做网站好吗网络营销方式落后的表现
  • 网站设计的主要机构有哪些wordpress固定连接怎么设置最好
  • 网站建设预付费入什么科目云南昆明网络公司有哪些
  • 上线了做的网站怎么办竞价可以做两个网站吗
  • 网站锚文本app制作平台推荐
  • 网站制作和设计需要多少钱wordpress改成自己网站
  • 我想在阿里巴巴上给别人做网站公司网站建设哪家公司好
  • 推广网站平台有哪些优化网站除了百度站长
  • 建设银行官方个人网站邢台网站建设公司
  • 南阳网站排名优化公司简单扁平化风格后台网站模板
  • 达人设计网官方网站龙华网站-建设深圳信科
  • asp企业网站源码网站建设论文二稿
  • 沧州市做网站价格自媒体app推广
  • 网站前端设计培训绵阳网站设计制作
  • 网站建设与维护前景哪个网站做校招
  • 使用h5做的学习网站源码ui设计官网
  • 酒店 深圳 网站建设wordpress 占内存
  • 竹子建站教程老网站做seo能不能重新注册
  • 手机微网站尺寸网站建设备案信息
  • 做logo的网站网站代下单怎么做