vue的基本用法

公共样式---pc版的404报错

动态src
这个是vue组件template部分

 <div class="not-found">
        <img :src="img" alt="404">
    </div>
     <div>{{fish}}</div>

script部分

import './404.css'   //先引入less
import img from './error-404.png'
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: '你还没有登录,请先登录',
      img, //es6用法   等同于  img:img
      fish:'你好'
    }
  }
}

引入的404.css部分

.not-found {
    margin: 10% 0 0;
    text-align: center;
}

下面是现象

公共样式loading pc端,根据传过来的参数,来显示loading
style用法
父组件:

<template>
     <!-- 显示loading -->
     <Load :option="test"></Load>
  </div>
</template>
<script>
import load from './loading'
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: '你还没有登录,请先登录',
      test:{
        show:true,
        progress:60
      }
    }
  },
  components:{
    Load:load
  }
}
</script>

子组件

<template>
  <div class="hello">
     哈哈哈
     <!-- 显示loading -->
    <div class="loadingbar-wrapper" v-show="option.show">
        <div id="loadingbar" class="waiting" :style="{ width: option.progress+'%'}">
            <dt></dt><dd></dd>
        </div>
    </div>

  </div>
</template>

<script>

export default {
  name: 'HelloWorld',
  props:['option'],
  data () {
    return {
      msg: '你还没有登录,请先登录'
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
@import "../assets/var.less";
@loading-bar-color: @color-white;
#loadingbar {
  position: fixed;
  z-index: 2147483647;
  top: 100px;
  left: -6px;
  width: 1%;
  height: 2px;
  background: @loading-bar-color;
  -moz-border-radius: 1px;
  -webkit-border-radius: 1px;
  border-radius: 1px;
  -moz-transition: all 500ms ease-in-out;
  -ms-transition: all 500ms ease-in-out;
  -o-transition: all 500ms ease-in-out;
  -webkit-transition: all 500ms ease-in-out;
  transition: all 500ms ease-in-out;
}

#loadingbar.left {
  left: 100%;
  right: 0px;
  width: 100%;
}

#loadingbar.up {
  left: 0px;
  top: 100%;
  width: 5px;
  bottom: 0px;
  height: 100%;
}

#loadingbar.down {
  left: 0;
  width: 5px;
  height: 0;
}

#loadingbar.waiting dd, #loadingbar.waiting dt {
  -moz-animation: pulse 2s ease-out 0s infinite;
  -ms-animation: pulse 2s ease-out 0s infinite;
  -o-animation: pulse 2s ease-out 0s infinite;
  -webkit-animation: pulse 2s ease-out 0s infinite;
  animation: pulse 2s ease-out 0s infinite;
}

#loadingbar dt {
opacity: .6;
width: 180px;
right: -80px;
clip: rect(-6px,90px,14px,-6px);
}

#loadingbar dd {
  opacity: .6;
  width: 20px;
  right: 0;
  clip: rect(-6px,22px,14px,10px);
}

#loadingbar dd, #loadingbar dt {
  position: absolute;
  top: 0;
  height: 2px;
  -moz-box-shadow: rgb(255, 156, 50) 1px 0 6px 1px;
  -ms-box-shadow: rgb(255, 156, 50) 1px 0 6px 1px;
  -webkit-box-shadow: rgb(255, 156, 50) 1px 0 6px 1px;
  box-shadow: rgb(255, 156, 50) 1px 0 6px 1px;
  -moz-border-radius: 100%;
  -webkit-border-radius: 100%;
  border-radius: 100%;
}

#loadingbar.left dt {
opacity: .6;
width: 180px;
left: -4px;
clip: rect(-6px,185px,14px,25px);
}

#loadingbar.left dd {
  opacity: .6;
  width: 20px;
  left: 0;
  margin: 0;
  clip: rect(-6px,22px,14px,0px);
}

#loadingbar.left dd, #loadingbar.left dt {
  top: 0;
  height: 2px;
}

#loadingbar.down dt {
  opacity: .6;
  height: 180px;
  top: auto;
  bottom: -47px;
  clip: rect(-6px,20px,130px,-6px);
}

#loadingbar.down dd {
  opacity: .6;
  height: 20px;
  top: auto;
  bottom: 0;
  clip: rect(-6px,22px,20px,10px);
  margin: 0;
}

#loadingbar.down dd, #loadingbar.down dt {
  left: -5px;
  right: auto;
  width: 10px;
}

#loadingbar.up dt {
  opacity: .6;
  height: 180px;
  bottom: auto;
  top: -10px;
  clip: rect(13px,20px,190px,-6px);
}

#loadingbar.up dd {
  opacity: .6;
  height: 20px;
  bottom: auto;
  top: 0;
  clip: rect(-6px,22px,25px,10px);
  margin: 0;
}

#loadingbar.up dd, #loadingbar.up dt {
  left: -5px;
  right: auto;
  width: 10px;
}

@keyframes pulse {
  30% { opacity:0.6; }
  60% { opacity:0; }
  100% { opacity:0.6; }
}

@-moz-keyframes pulse
{
  30% { opacity:0.6; }
  60% { opacity:0; }
  100% { opacity:0.6; }
}

@-ms-keyframes pulse
{
  30% { opacity:0.6; }
  60% { opacity:0; }
  100% { opacity:0.6; }
}

@-webkit-keyframes pulse
{
  30% { opacity:0.6; }
  60% { opacity:0; }
  100% { opacity:0.6; }
}

.loadingbar-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1000;
  width: 100%;
}

.loadingbar-wrapper::after {
  position: absolute;
  right: 5px;
  top: 10px;
  z-index: 1001;
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 100%;
  -webkit-animation-fill-mode: both;
          animation-fill-mode: both;
  border: 2px solid @loading-bar-color;
  border-bottom-color: transparent;
  -webkit-animation: rotate 0.75s 0s linear infinite;
          animation: rotate 0.75s 0s linear infinite;
}

@keyframes rotate {
  0% {
    -webkit-transform: rotate(0deg);
            transform: rotate(0deg); }
  100% {
    -webkit-transform: rotate(360deg);
            transform: rotate(360deg) }
}
</style>

效果 :

这个位置会根据传过来的数不一样而移动,这里主要是父传子的实际应用吧~

原文地址:https://www.cnblogs.com/antyhouse/p/9412199.html

时间: 2024-08-29 11:29:35

vue的基本用法的相关文章

Vue组件基础用法

前面的话 组件(Component)是Vue.js最强大的功能之一.组件可以扩展HTML元素,封装可重用的代码.根据项目需求,抽象出一些组件,每个组件里包含了展现.功能和样式.每个页面,根据自己所需,使用不同的组件来拼接页面.这种开发模式使前端页面易于扩展,且灵活性高,而且组件之间也实现了解耦.本文将详细介绍Vue组件基础用法 概述 组件是一个自定义元素或称为一个模块,包括所需的模板.逻辑和样式.在HTML模板中,组件以一个自定义标签的形式存在,起到占位符的功能.通过Vue.js的声明式渲染后,

vue路由高级用法

五.路由设置高级用法alias 别名 {path:'/list',component:MyList,alias:'/lists'}redirect 重定向 {path:'/productList',redirect:'/list'}path:'*' 异常处理 {path:'*',component:'NotFound'} <!doctype html> <html> <head> <meta charset="UTF-8"> <ti

vue的基础用法

基础用法(没有搭建框架就在html文件里演示) 一. Hello World起步 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Hello World</title> </head> <body> <!-- 模板 --> <div id="app&qu

cdn模式下vue的基本用法

我们知道jq是简化了dom操作,而react和vue则是通过使用虚拟dom的方式,不需要频繁的更改ui界面,而是通过更改数据的方式来更新界面. 我们知道些jq插件时会在IFFE中传入jQuery,jQuery在此程序中映射为符号,这样可以避免$号被其他库覆写.其实vue中new Vue()对象, 效果也是类似,可以避免vue范围类的数据或变量被污染. 我们先来看一些基本的用法 插入文本值 v-html 直接插入html结构 v-bind属性 <a :href="url">

Vue SSR: 基本用法 (二)

上一篇讲解了ssr的原理,这篇主要讲基本用法: 1.安装 npm install vue vue-server-renderer --save 我们将在整个指南中使用 NPM,但你也可以使用 Yarn. 注意: 推荐使用 Node.js 版本 6+ . vue -server -renderer 和 vue 必须匹配版本. 必须匹配版本. vue -server -renderer 依赖一些 Node.js  原生模块,因此只能在 Node.js原生模块 中使用. 我们可能会提供一个更简单的构建

Vue:基本用法。

一.起步 1.下载核心库vue.js bower info vue #查看版本号 npm init --yes #下载vue.js cnpm install vue --save 版本 v2.5.17 目前最新版本() vue2.0比1.0相比最大的变化就是引入Virtual DOM(虚拟DOM),页面更新效率高,速度更快 2.hello world(对比 angular)2.1angular实现 js: let app=angular.module("myApp",[]) app.c

分享vue中 slot用法

//slot默认用法 //slot带参数name用法

vue 模版组件用法

第一种 //首先,别忘了引入vue.js <div id="user_name_01"></div> <script src="../node_modules/vue/dist/vue.js"></script> <script> var User_01 = Vue.extend({// 创建可复用的构造器 template: '<p>{{firstName}} {{lastName}} age

vue动画的用法

vue动画 在vue.js中有两种写动画的方法,第一种就是像js里一样,用原生代码来实现,第二种则是使用animate.css的动画类文件,这个动画类和bootstrap.css文件类似,直接调用类就可以了,话不多说,直接上代码. 一.vue.js原生动画 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title></title>