zoukankan      html  css  js  c++  java
  • 前台

    前台

    vue环境

    1.傻瓜式安装node: 
    官网下载:https://nodejs.org/zh-cn/
    
    2.安装cnpm: 
    >: npm install -g cnpm --registry=https://registry.npm.taobao.org
    
    3.安装vue最新脚手架: 
    >: cnpm install -g @vue/cli
    
    注:如果2、3步报错,清除缓存后重新走2、3步
    >: npm cache clean --force
    

    创建项目

    """
    前提:在目标目录新建luffy文件夹
    >: cd 建立的luffy文件夹
    >: vue create luffycity
    """
    

    重构项目目录

    """
    ├── luffycity
    	├── public/          			# 项目共有资源
    		├── favicon.ico				# 站点图标
    		└── index.html				# 主页
        ├── src/      					# 项目主应用,开发时的代码保存
        	├── assets/      			# 前台静态资源总目录
        		├── css/				# 自定义css样式
        			└── global.css		# 自定义全局样式
        		├── js/					# 自定义js样式
    				└── settings.js		# 自定义配置文件
    			└── img/				# 前台图片资源
    		├── components/    			# 小组件目录
    		├── views/  				# 页面组件目录
    		├── App.vue	    			# 根组件
    		├── main.js	    			# 入口脚本文件
    		├── router    		
    			└── index.js			# 路由脚本文件
    		store	    		
    			└── index.js			# 仓库脚本文件
        ├── vue.config.js	    		# 项目配置文件
        └── *.*							# 其他配置文件
    """
    

    文件修订:目录中非配置文件的多余文件可以移除

    App.vue
    <template>
        <div id="app">
            <router-view/>
        </div>
    </template>
    
    router/index.js
    import Vue from 'vue'
    import VueRouter from 'vue-router'
    import Home from '../views/Home.vue'
    
    Vue.use(VueRouter);
    
    const routes = [
        {
            path: '/',
            name: 'Home',
            component: Home
        },
        {
            path: '/home',
            redirect: '/',
        },
    ];
    
    const router = new VueRouter({
        mode: 'history',
        base: process.env.BASE_URL,
        routes
    })
    
    export default router
    
    
    Home.vue
    <template>
        <div class="home">
        </div>
    </template>
    
    <script>
        export default {
            name: 'home',
            components: {
            },
        }
    </script>
    

    全局配置:全局样式、配置文件

    global.css
    /* 声明全局样式和项目的初始化样式 */
    body, h1, h2, h3, h4, h5, h6, p, table, tr, td, ul, li, a, form, input, select, option, textarea {
        margin: 0;
        padding: 0;
        font-size: 15px;
    }
    
    a {
        text-decoration: none;
        color: #333;
    }
    
    ul {
        list-style: none;
    }
    
    table {
        border-collapse: collapse; /* 合并边框 */
    }
    
    settings.js
    export default {
        base_url: 'http://127.0.0.1:8000'
    }
    
    main.js
    // 配置全局样式
    import '@/assets/css/global.css'
    
    // 配置全局自定义设置
    import settings from '@/assets/js/settings'
    Vue.prototype.$settings = settings;
    // 在所有需要与后台交互的组件中:this.$settings.base_url + '再拼接具体后台路由'
    
  • 相关阅读:
    Power BI 根据用户权限动态生成导航跳转目标
    Power BI Tooltips 增强功能
    Power BI refresh error “could not load file or assembly…provided impersonation level is invalid”
    SQL 错误代码 18456
    如何使用SQL Server Integration Services从多个Excel文件读取数据
    通过表格编辑器将现有表引入Power BI数据流
    Power BI 中动态增长的柱状图
    ambari2.7.3离线安装hdp3.1.0时,ambari-hdp-1.repo中baseurl无值
    ambari 安装 cannot download file mysql-connector-java from http://8080/resource/mysql-connector-java.jar
    洛谷P4180 [BJWC2010]严格次小生成树
  • 原文地址:https://www.cnblogs.com/kai-/p/12368788.html
Copyright © 2011-2022 走看看