2020-9-11 vue lottie datav svg

438 阅读1分钟

vue v-html

需要在v-html的html字符串的button中绑定点击事件,需要点击后做一些操作,必须渲染成html,但是渲染后的html里面写绑定事件的代码没有经过vue编译,所以事件无效。

<div class="code-review">
  <div v-html="html" v-highlight @click="addComment($event)"></div>
</div>
 
  
computed: {
  html () {
   return '<button></button >'
  },
 },

解决办法:

在v-html同级元素中使用事件绑定,然后根据事件触发的目标对象去判断和获取参数。

addComment:function (event) {
 if(event.target.nodeName === 'BUTTON'){
 // 获取触发事件对象的属性
 alert("a");
 }
}

public assets

参考链接 public放不会变动的文件(相当于vue-cli2.x中的static)

public/ 目录下的文件并不会被Webpack处理:它们会直接被复制到最终的打包目录(默认是dist/static)下。必须使用绝对路径引用这些文件,这个取决于你vue.config.js中publicPath的配置,默认的是/。

assets放可能会变动的文件

assets目录中的文件会被webpack处理解析为模块依赖,只支持相对路径形式。

简单来说就是就是public放别人家js文件(也就是不会变动),assets放自己写的js文件(需要改动的文件)

lottie

使用

引入

import  animationData1 from "../assets/node_1.json"; 

data(){
  return{
    defaultOption1: { animationData: animationData1 },
  }
}

使用

<lottie class="img4"   :options="defaultOption1"   :height="200" :width="200" v-on:animCreated="handleAnimation" />

handleAnimation: function(anim) {
        this.anim = anim;
        console.log(anim); //这里可以看到 lottie 对象的全部属性

解析

链接 链接

datav

官网

安装引入

npm install @jiaminghi/data-view
import dataV from '@jiaminghi/data-view'

Vue.use(dataV)

全屏容器

<dv-full-screen-container>content</dv-full-screen-container>

使用前请注意将body的margin设为0,否则会引起计算误差,全屏后不能完全充满屏幕。

动态环图

基于Charts封装。

<dv-active-ring-chart :config="config" style="width:300px;height:300px" />

飞线图(不满足需求未使用)

<dv-flyline-chart-enhanced :config="config" style="width:100%;height:100%;" />

svg animate

链接

attributeName 需要动画的属性名称 from 属性的初始值 to 终止值 dur 动画的时间