当前位置:   article > 正文

使用HBuilderX搭建uni-app_hbuilderx运行uniapp

hbuilderx运行uniapp

 

uni-app 是一个使用 Vue.js 开发所有前端应用的框架,开发者编写一套代码,可发布到iOS、Android、Web(响应式)、以及各种小程序(微信/支付宝/百度/头条/QQ/钉钉/淘宝)、快应用等多个平台。

查看更多

1、工具安装

HBuilderX:官方IDE下载地址

2、创建uni-app

创建项目:

创建完后目录结构(common目录是手动创建的)

3、使用vuex

vuex是HBuilderX已经内置好了,可以直接使用

代码如下

index.js

  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import componentView from './modules/componentView'
  4. Vue.use(Vuex)
  5. const store = new Vuex.Store({
  6. // 开启严格模式 确保state 中的数据只能 mutations 修改 不开启就可以随便修改
  7. //strict:true,
  8. state: {
  9. },
  10. mutations: {
  11. //
  12. },
  13. actions: {
  14. //
  15. },
  16. modules: {
  17. componentView
  18. }
  19. })
  20. export default store;

componentView.js

  1. /**
  2. * 动态组件状态
  3. * @type {{state: {componentView: string}, mutations: {setRoleManageDetailState(*, *): void, setAuthoritySettingState(*, *): void}, getters: {getRoleManageDetail: (function(*): *)}, actions: {showRoleManageDetail({commit: *}, *=): void, showAuthoritySetting({commit: *}, *=): void}}}
  4. */
  5. const componentView = {
  6. state: {
  7. componentView: Math.ceil(Math.random()*1000)
  8. },
  9. mutations: {
  10. setComponentViewState (state, flg) {
  11. state.componentView = flg
  12. }
  13. },
  14. getters: {
  15. getComponentViewState: state => {
  16. return state.componentView
  17. }
  18. },
  19. actions: {
  20. showComponentView ({ commit }, flg) {
  21. commit('setComponentViewState', flg)
  22. },
  23. showMathComponentView ({ commit }) {
  24. let number = Math.ceil(Math.random()*1000);
  25. console.log(number);
  26. commit('setComponentViewState', number)
  27. }
  28. }
  29. }
  30. export default componentView

修改main.js

4、测试

以上项目基本框架已经搭建好了。下面就是模拟运行了。

双击manifest.json配置,进行自定义配置即可。

需要配置微信开发工具安全设置,如图

 

运行结果:

 

 

以上就是一个简单的uni-app搭建过程。

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/227472
推荐阅读
相关标签
  

闽ICP备14008679号