Giter VIP home page Giter VIP logo

github展示页面


在git 创建仓库,按照 GitHub Pages 的规定,名称为 username.github.io 的项目的master 分支,或者其它名称的项目的 gh-pages 分支可以自动生成 GitHub Pages 页面;这里我们利用gh-pages展示。

vue-cli创建一个简单的个人简历页面

使用到的技术:

  • Node
  • webpack
  • Vue/Vue-router/Vue-cli
  • Echarts
  • ElementUI

步骤

  • 首先在远程仓库创建一个RaiyenXiao仓库,拉去仓库到本地
  • 利用Vue-cli快速构建一个项目 方法查看 Vue-cli快速构建规范的VUE项目骨架
  • 在项目中安装ECharts依赖,使用requrie按需引用图表组件:
cnpm i echarts -S
  • 安装ElementUI :

    1. 安装 ElementUI
    npm i element-ui -S
    
    1. 安装 babel-plugin-component
    npm i babel-plugin-component -D
    
    1. 修改 .babelrc
    {
    "presets": [
      ["env", {
        "modules": false,
        "targets": {
          "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
        }
      }],
      "stage-2"
    ],
    "plugins": [
      "transform-vue-jsx", 
      "transform-runtime",
      [
        "component",
        {
          "libraryName": "element-ui",
          "styleLibraryName": "theme-chalk"
        }
      ]
    ]
    }
    
    1. 按需引入 Row 与 Col:

    main.js:

    import Vue from 'vue'
    import App from './App'
    import router from './router'
    
    Vue.config.productionTip = false
    
    // 引入样式重置
    import '../static/css/reset.css'
    
    // 引入及使用 ElementUI
    import {Row, Col} from 'element-ui';
    Vue.use(Row).use(Col);
    
    new Vue({
      el: '#app',
      router,
      components: { App },
      template: '<App/>'
    })
    
  • 完成项目模块内容

  • 执行cnpm run build打包项目

此命令完成后,目录下会多出一个dist文件夹,包含一个static文件夹和indexe.html;static文件下包括项目打包后的css、js、img、fonts(字体图标)。

点击index.html,浏览器显示该页面是空白的,发现项目资源无法加载

解决方案

  • 打开项目根目录config下的index.js文件,将assetsPublicPath: '/',改为assetsPublicPath: './' ,
  • 字体图标无法加载 ,打开build中的 utils.js 文件,在控制build样式文件代码中添加 publicPath: '../../'
    if (options.extract) {
      return ExtractTextPlugin.extract({
        use: loaders,
        fallback: 'vue-style-loader',
        publicPath: '../../'
      })
    }
  • 生成gh-pages分支

创建gh-pages分支,分支下存放dist文件夹下的内容,其余都删除,讲gh-pages分支推送到远程仓库

  • 点击项目仓库的setting,找到source,切换到gh-pages branch,点击保存

访问 https://raiyenxiao.github.io/RaiyenXiao/#/

RaiyenXiao's Projects

blog icon blog

冴羽写博客的地方,预计写四个系列:JavaScript深入系列、JavaScript专题系列、ES6系列、React系列。

live2d-widget icon live2d-widget

把萌萌哒的看板娘抱回家 | Live2D widget for web platform

nodejs-test1 icon nodejs-test1

功能:登录注册,管理员可进入后台,用户管理分页

note icon note

一些前端相关的笔记、记录、练习

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.