vue - blog开发学习1

1、安装vue-cli

  vue intall -g vue-cli

2、创建项目

  vue init webpack nblog

3、按提示要求配置项目

? Project name nblog
? Project description 学习bolg开发
? Author nxzJIA <987097855@qq.com>
? Vue build standalone
? Install vue-router? Yes
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Set up unit tests No
? Setup e2e tests with Nightwatch? No
? Should we run `npm install` for you after the project has been created? (recommended) npm

   vue-cli · Generated "nblog".

4、创建完成之后,用webstorm导入项目,如下图

5、启动项目,项目默认的主页

6、为了方便开发,会使用iviewui

需要在main.js中添加:

import iView from ‘iview‘

Vue.use(iView)

7、改造项目

创建自己的主页路由home.vue(顶级路由,其他所有路由的内容都要渲染到该路由)

在src/components下创建home.vue

home.vue中布局:上中下布局使用iview的Layout标签,上侧显示为菜单(固定上侧不动)、中(内容显示区域)、下(待定)

8、顶部菜单路由,采用最简单的形式,点击手也是,主体部分会心事相应的内容

import Vue from ‘vue‘
import Router from ‘vue-router‘
import Home from ‘@/components/home‘
import Index from ‘@/components/index‘
import Create from ‘@/components/create‘
import Edit from ‘@/components/edit‘
import PostClass from ‘@/components/post-class‘
import AboutMe from ‘@/components/about-me‘

Vue.use(Router)

export default new Router({
  mode:‘history‘,
  routes: [
    {
      path: ‘/‘,
      name: ‘Home‘,
      component: Home,
      children:[
        {
          path: ‘/index‘,
          name: ‘Index‘,
          alias:‘/‘,
          component: Index
        },
        {
          path: ‘/create‘,
          name: ‘Create‘,
          component: Create
        },
        {
          path: ‘/edit‘,
          name: ‘Edit‘,
          component: Edit
        },
        {
          path: ‘/postClass‘,
          name: ‘PostClass‘,
          component: PostClass
        },
        {
          path: ‘/aboutMe‘,
          name: ‘AboutMe‘,
          component: AboutMe
        },
      ]
    },

  ]
})

home.vue

<template>
  <div class="layout">
    <Layout>
      <Header :style="{position: ‘fixed‘, width: ‘100%‘}">
        <Menu mode="horizontal" theme="dark" active-name="1">
          <div class="layout-logo">
            <img src="static/img/logo.png" alt="">
          </div>
          <div class="layout-nav">
            <MenuItem name="1" to="index">
              <Icon type="ios-navigate"></Icon>
              首页
            </MenuItem>
            <MenuItem name="2" to="postClass">
              <Icon type="ios-keypad"></Icon>
              类别
            </MenuItem>
            <MenuItem name="3" to="create">
              <Icon type="ios-analytics"></Icon>
              新建
            </MenuItem>
            <MenuItem name="4" to="edit">
              <Icon type="ios-paper"></Icon>
              修改
            </MenuItem>
            <MenuItem name="5" to="aboutMe">
              <Icon type="ios-paper"></Icon>
              关于我
            </MenuItem>
          </div>
        </Menu>
      </Header>

      <Content :style="{margin: ‘88px 20px 0‘, background: ‘#fff‘, minHeight: ‘500px‘}">
        <router-view></router-view>
      </Content>
      <Footer class="layout-footer-center">2011-2016 &copy; TalkingData</Footer>
    </Layout>
  </div>
</template>

<script>
  export default {
    name: "home"
  }
</script>

<style scoped>
  @import "../static/css/home.css";

</style>

index.vue

<template>
<div>
  index
</div>
</template>

<script>
    export default {
        name: "index"
    }
</script>

<style scoped>

</style>

其他的也类似(一开始就是个简单的布局,后序内容陆续添加)

这样页面的基本功能添加完毕

原文地址:https://www.cnblogs.com/nxzblogs/p/10914042.html

时间: 2024-08-30 18:12:14

vue - blog开发学习1的相关文章

vue - blog开发学习2

首页博客列表的开发 1.修改index.vue,使能够支持列表功能 <template> <div> <PostList v-for="(item,index) in postList" :title="item.title" :content="item.content" :postCount="postCount" :key="index"></PostList

vue - blog开发学习5

基本功能和后台联调 1.首页的所有博客 因为是前后台都是本地开发,所以前端vue需要设置proxy:修改/config/index.js中的这个proxyTable proxyTable: { '/api': { target: 'http://localhost:8888', changeOrigin: true, pathRewrite: { '^/api': '' } }, 同时将mock.js中的模拟数据方法注释掉 2.后台添加cors package com.nxz.blog.conf

vue - blog开发学习6

1.问题,如下图,使用iviewui中的card导致页面不能出现滚动条(不太会弄,在网上查了一个vue组件vuescroll,因此使用这个做滚动条) 2.安装vuescroll cnpm install -S vuescroll https://vuescrolljs.yvescoding.org/zh/guide/getting-started.html#%E5%AE%89%E8%A3%85 3.问题:项目使用的jpa操作数据库,因为postclass和post是多堆多的关系,因此post.j

web前端开发学习课程大纲路线图及学习方法分享

想学好web前端开发,要学会阅读别人优秀的代码.web前端开发思想并不是统一固定不变的,阅读别人代码的过程就是间接的在向别人学习,这一过程中可以学习别人的开发思路,不同的人思路是不一样的,如果别人写的代码很优秀.很简单.且运行和性能上有很大的优势,就有很多可以借鉴的地方. 以下这份web前端学习路线图适合所以零基础的学员学习,都是从浅入深,没有基础的同学跟着视频教程及课程大纲一步一步的学习是可以很好的掌握的. 那么想要学好html5前端开发,那么需要掌握的专业技术有: 第一阶段:前端页面重构 内

Android开发学习之路--网络编程之xml、json

一般网络数据通过http来get,post,那么其中的数据不可能杂乱无章,比如我要post一段数据,肯定是要有一定的格式,协议的.常用的就是xml和json了.在此先要搭建个简单的服务器吧,首先呢下载xampp,然后安装之类的就不再多讲了,参考http://cnbin.github.io/blog/2015/06/05/mac-an-zhuang-he-shi-yong-xampp/.安装好后,启动xampp,之后在浏览器输入localhost或者127.0.0.1就可以看到如下所示了: 这个就

Android开发学习---使用XmlPullParser解析xml文件

Android中解析XML的方式主要有三种:sax,dom和pull关于其内容可参考:http://blog.csdn.net/liuhe688/article/details/6415593 本文将主要介绍pull解析器解析xml文件,环境为ubuntu 12.04+ intelij 13.1 + android sdk 2.1 一.创建一个XML项目,步骤如下: 二.解析一个xml文件: assets/person.xml <?xml version="1.0" encodi

.net 网站开发学习资源

慕课网 前端基础学习 http://www.imooc.com/course/list?c=fe 了解需求 例子之一 http://wenku.it168.com/d_000517899.shtml mvc教程 http://blog.csdn.net/powertoolsteam/article/details/47609257 asp.net 的使用类大全 http://git.oschina.net/kuiyu/dotnetcodes/blob/master/DotNet.Utilitie

[Android游戏开发学习笔记]View和SurfaceView

本文为阅读http://blog.csdn.net/xiaominghimi/article/details/6089594的笔记. 在Android游戏中充当主要角色的,除了控制类就是显示类.而在Android中涉及到显示的是View类,及继承自它的SurfaceView类和SurfaceView的其他子类等. 这里先只说View和SurfaceView.SurfaceView的直接子类有GLSurfaceView和VideoView,可以看出GL和视频播放以及CAmera摄像头一般均使用Su

Vue.js 基础学习

今天我开始了Vue.js 的学习. 那么什么是Vue.js 呢? Vue.js是一套开发Web页面的JavaScript脚本框架.听起来感觉很难,不过据说,Vue.js是Web-Javascript脚本框架中最容易上手的框架.所以我便选择了先来学习这个. 要学习Vue.js首先就要获取库文件了,在网上有很多地方可以找到,我是在bootcdn上找到的 接下来我们通过Vue输出一串Hello World ! 首先引入vue. <script src="https://cdn.bootcss.c