1 Star 0 Fork 0

falcon / vue-firebase-study

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
GPL-3.0

#学习Vue 和 Firebase

🛠️ 资源

Vue.js 官网中文文档 (v2) Vue-cli github Vue-cli (Vue.js 开发的标准工具)

Day 1

  • Vue.js的引入
  • 数据绑定
  • 在模板使用函数
  • 在模板中绑定属性v-bind ,可以使用 : 简写
  • 在模板中绑定事件 v-on ,使用@简写,如 @click="methodName"
  • 使用 v-model (未深入)
  • 使用 修饰器 键盘/事件 修饰器,(未深入)
  • 模板基本语法,条件,循环(未深入)

Day 2

因为版本更新,这块跟视频的差别很大,当前使用 版本 vue --version

@vue/cli 4.3.1

  • vue-cli 安装:

    npm install -g @vue/cli

    快速原型开发 vue serve ,默认入口可以是 main.js、index.js、App.vue 或 app.vue 中的一个

  • 创建一个项目

    vue create yourProject

    运行

    cd yourProjectPath
    npm run serve
    # 相当于
    node_modules/.bin/vue-cli-service serve

    查错

    npm run lint

    以上命令注册在项目的 package.jsonscripts项中
    创建项目时可以设定配置,加入相应的组件

  • 保存预设配置

  • 安装plugins 如安装 vue-plugin-vuetify 对应到 package.jsondevDependencies项目

    vue add vuetify       

Day3

  • 构建web component

    用法

    vue build  -h 
    -t, --target <target>  Build target (app | lib | wc | wc-async, default: app)
    -n, --name <name>      name for lib or web-component mode (default: entry filename)
    -d, --dest <dir>       output directory (default: dist)
    -h, --help             output usage information

    如将online.vue构建为online-statusweb component

    vue build online.vue --target wc --name online-status    
  • 使用 web component 如使用之前构建的 online-status

    <meta charset="utf-8">
    <title>online-status demo</title>
    <script src="https://unpkg.com/vue"></script>
    <script src="./online-status.js"></script>
    ...
    <online-status status="online"></online-status>
    ...
    
  • vue ui 图形化工具 vue-cli 的 web图形化 界面

day4 -> day5

- ES6
- async 

- promise 

- await

day6

2020.07.24

  • 不必记住vue的npm run命令,因为项目的package.json文件可以找到这些命令
 "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  }
  • 运行开发服务器时出错 npm run serve
> vue-tobe@0.1.0 serve /Users/falcon/projects/js/vue-firebase/day6/vue-tube
> vue-cli-service serve

 INFO  Starting development server...
 ERROR  Error: No valid exports main found for '/Users/falcon/projects/js/vue-firebase/day6/vue-tube/node_modules/colorette'
Error: No valid exports main found for '/Users/falcon/projects/js/vue-firebase/day6/vue-tube/node_modules/colorette'

解决方法有两个:

1. `npm i colorette@1.2.0`  # 必须带版本号才管用 

2. 升级 `node.js` 
    `homebrew`安装的 `node.js` 有时并不是最新的版本,就算使用homebrew升级也升不到官方最新版本。`N`是node内置的版本管理器,使用`npm install -g n`安装,然后执行 `sudo n latest` 可升到最新版本。

day 7

2020.07.30

安装nvm ,node版本管理工具。 项目用法和文档

brew install nvm

常用的指令

  • 查看版本
nvm ls-remote #远程所有node版本
nvm ls #本地所有安装的node版本
  • 安装
nvm install 版本 #如果版本写node,会安装最新版本的node并自动切换,如果填写lts,会安装lts版本,如果填写具体版本号,会安装指定版本
  • 设置默认版本
nvm alias default node #使用最新版本
nvm alias default 'lts/*' #使用 `lts/*` 版本
nvm alias default 12.18.3 #使用 `12.18.3`版本
  • 切换当前使用的node版本
nvm use #会使用~/.nvmrc 指定的 node 版本
nvm use 12.18.3  #使用12.18.3版本
nvm use node/stable/unstable #切换最新版本/稳定版本/lts
  • 删除node版本
nvm uninstall 8 #删除8.x版本
nvm uninstall unstable #删除unstable版本

ps: 使用nvm管理node版本后,全局安装模块时不需要用sudo

day8

2020.08.08

vue文档学习

  • Vue 实例还暴露了一些有用的实例属性与方法。 它们都有前缀 $ 如:
var vm = new Vue(
    el:'#app',
    data:{
        name:"falcon"
    }
)
console.log('实例属性')
console.log(vm.$el)
console.log(vm.$data)
console.log (vm.$el === document.getElementById('app')) // => true


// 这个回调将在 `vm.wage` 改变后调用

vm.$watch('wage', function(newVal, oldVal) {
  console.log(this, `wage change from ${oldVal} to ${newVal}`)
  }
);
  • 不要在生命周期或实例方法里使用箭头函数,

如:

created: () => console.log(this.a)
vm.$watch('wage', (newVal, oldVal) => console.log(this,`wage change from ${oldVal} to ${newVal}`)) //这个this会向上查找不是vue实例,而是window

因为箭头函数并没有 thisthis 会作为变量一直向上级词法作用域查找,直至找到为止,经常导致 Uncaught TypeError: Cannot read property of undefinedUncaught TypeError: this.myMethod is not a function 之类的错误

不改变值

<span v-once>这个值不会改变:  wage: {{wage}}</span>

输出原始html

<span v-html="rawHtml"></span>

动态绑定属性/事件

好像这个动态绑定的属性和事件名不能用驼峰写法?会自动转化成小写的data属性

<a v-bind:[attr]="url"> 动态绑定属性 </a>
<a v-on:[eventname]="doSomething"> 动态绑定事件 </a>
  • 计算属性
computed: { //计算属性

    reversedName: function () {
      return this.name.split('').reverse().join('')  
    }

  },

计算属性是基于它们的响应式依赖进行 缓存 的,只有相关的响应式依赖发生变化时才会重新计算。 相比之下,每当触发重新渲染时,调用方法将总会再次执行函数。

  • 侦听属性
  watch: {
    firstName: function (val) {
      this.fullName = val + ' ' + this.lastName
    },
    lastName: function (val) {
      this.fullName = this.firstName + ' ' + val
    }
  }

尽量使用计算属性而不是命令式的 watch 回调

  • 计算属性的 setter

运行 vm.label2 = "test" 时,setter 会被调用

computed:{
    label2: {

        get() { //getter
        return this.name + this.age + '@' + Date.now()
        },
        set() { //setter
        console.log('Changed @' + Date.now())
        this.name += ' hack';
        
        }
    }
}
  • 侦听器
watch: {
    ...
}

vue项目的bin目录位于 node_modules/.bin/ 运行npm run serve 相当于 node_modules/.bin/vue-cli-service serve

vue.js为什么在component的template的root标签中不能使用v-for?

如果后续安装 vue-router插件,App.vue 会被覆盖

  • 使用 Netlify 免费部署

参考视频: Deploy Websites In Seconds With Netlify

部署了github page:https://amazing-goldstine-c1bf0b.netlify.app/

day9

2020.08.10

  • 向组件中增加class 当在一个自定义组件上使用 class property 时,这些 class 将被添加到该组件的根元素上面。这个元素上已经存在的 class 不会被覆盖。 如:

组件Header.vue:


<template>
  <h1 class="header">header</h1>
  ...
</template>

引入Header的组件

import Header from '../components/Header.vue'

<template>
<div id="app">
  <Header class="custom-header">
  ...
</div>
</tempate>

最后会被渲染为:

<h1 class="header custom-header">header</h1>
  • 绑定内联样式 v-bind:style 的对象语法十分直观——看着非常像 CSS,但其实是一个 JavaScript 对象。CSS property 名可以用驼峰式 (camelCase) 或短横线分隔 (kebab-case,记得用引号括起来) 来命名
<div v-bind:style="{ color: activeColor, fontSize: fontSize + 'px' }"></div>
data: {
  activeColor: 'red',
  fontSize: 30
}
  • 用 key 管理可复用的元素
<template v-if="loginType === 'username'">
  <label>Username</label>
  <input placeholder="Enter your username" key="username-input">
</template>
<template v-else>
  <label>Email</label>
  <input placeholder="Enter your email address" key="email-input">
</template>

如果不设置key时,loginType 变化时,input 内的输入值会保留,仅placeholer会被替换

  • 不推荐同时使用 v-if 和 v-for

当 v-if 与 v-for 一起使用时,v-for 具有比 v-if 更高的优先级。

  • v-for 列表渲染

语法:

  <li v-for="item in items" :key="item.message">
    {{ item.message }}
  </li>

支持第二个参数:索引

  <li v-for="(item, index) in items">
    {{ parentMessage }} - {{ index }} - {{ item.message }}
  </li>
  • v-for 对象渲染

语法:

  <li v-for="value in object">
    {{ value }}
  </li>

第二个参数name表示对象属性名

 <div v-for="(value, name) in object">
  {{ name }}: {{ value }}
 </div>

第三个参数index表示索引

<div v-for="(value, name, index) in object">
  {{ index }}. {{ name }}: {{ value }}
</div>
  • 在计算属性不适用的情况下 (例如,在嵌套 v-for 循环中) 你可以使用一个方法:
<ul v-for="set in sets">
  <li v-for="n in even(set)">{{ n }}</li>
</ul>
data: {
  sets: [[ 1, 2, 3, 4, 5 ], [6, 7, 8, 9, 10]]
},
methods: {
  even: function (numbers) {
    return numbers.filter(function (number) {
      return number % 2 === 0
    })
  }
}
  • 2.2.0+ 的版本里,当在组件上使用 v-for 时,key 现在是必须的。
<my-component
  v-for="(item, index) in items"
  v-bind:item="item"
  v-bind:index="index"
  v-bind:key="item.id"
></my-component>
  • 这里的 is="todo-item" attribute。这种做法在使用 DOM 模板时是十分必要的,因为在
      元素内只有
    • 元素会被看作有效内容。这样做实现的效果与 相同,但是可以避开一些潜在的浏览器解析错误。
     <li
          is="todo-item"
          v-for="(todo, index) in todos"
          v-bind:key="todo.id"
          v-bind:title="todo.title"
          v-on:remove="todos.splice(index, 1)"
        ></li>
    • 在内联语句处理器中访问原始的 DOM 事件。

      可以用特殊变量 $event 把它传入方法:

      <button v-on:click="warn('Form cannot be submitted yet.', $event)">
      Submit
      </button>
    • 访问原生事件对象

    methods: {
      warn: function (message, event) {
        // 现在我们可以访问原生事件对象
        if (event) {
          event.preventDefault()
        }
        alert(message)
        }
    }
    • 事件修饰符
     <!-- 阻止单击事件继续传播 -->
     <a v-on:click.stop="doThis"></a>
    
     <!-- 提交事件不再重载页面 -->
     <form v-on:submit.prevent="onSubmit"></form>
    
     <!-- 修饰符可以串联 -->
     <a v-on:click.stop.prevent="doThat"></a>
    
     <!-- 只有修饰符 -->
     <form v-on:submit.prevent></form>
    
     <!-- 添加事件监听器时使用事件捕获模式 -->
     <!-- 即内部元素触发的事件先在此处理,然后才交由内部元素进行处理 -->
     <div v-on:click.capture="doThis">...</div>
    
     <!-- 只当在 event.target 是当前元素自身时触发处理函数 -->
     <!-- 即事件不是从内部元素触发的 -->
     <div v-on:click.self="doThat">...</div>
     <!-- 点击事件将只会触发一次 -->
     <a v-on:click.once="doThis"></a>

    使用修饰符时,顺序很重要;相应的代码会以同样的顺序产生。因此,用 v-on:click.prevent.self 会阻止所有的点击,而 v-on:click.self.prevent 只会阻止对元素自身的点击。

    • 按键修饰符
    <!-- 只有在 `key` 是 `Enter` 时调用 `vm.submit()` -->
    <input v-on:keyup.enter="submit">

    任意有效按键名转换为 kebab-case 来作为修饰符。如: page-down

     <input v-on:keyup.page-down="onPageDown">
    • 系统修饰键

    在 Mac 系统键盘上,meta 对应 command 键 (⌘)。在 Windows 系统键盘 meta 对应 Windows 徽标键 (⊞)。

    <!-- Alt + C -->
    <input v-on:keyup.alt.67="clear">
    
    <!-- Ctrl + Click -->
    <div v-on:click.ctrl="doSomething">Do something</div>
    • v-model 指令在表单、<textarea> 及 元素上创建双向数据绑定。

    v-model 在内部为不同的输入元素使用不同的 property 并抛出不同的事件:

    • text 和 textarea 元素使用 value property 和 input 事件;
    • checkbox 和 radio 使用 checked property 和 change 事件;
    • select 字段将 value 作为 property 并将 change 作为事件。
    • 在文本区域插值 (<textarea>{{text}}</textarea>) 并不会生效,应用 v-model 来代替。
     <textarea v-model="message" placeholder="add multiple lines"></textarea>
    • 多个复选框,绑定到同一个数组:
    <input type="checkbox" id="jack" value="Jack" v-model="checkedNames">
    <label for="jack">Jack</label>
    <input type="checkbox" id="john" value="John" v-model="checkedNames">
    <label for="john">John</label>
    <input type="checkbox" id="mike" value="Mike" v-model="checkedNames">
    <label for="mike">Mike</label>
    <br>
    <span>Checked names: {{ checkedNames }}</span>
    new Vue({
      el: '...',
      data: {
        checkedNames: []
      }
    })

    day10

    2020.08.11

    checkName是一个数组 ,值为input里的value
    
    - 如果 v-model 表达式的初始值未能匹配任何选项,<select> 元素将被渲染为“未选中”状态。在 iOS 中,这会使用户无法选择第一个选项。因为这样的情况下,iOS 不会触发 change 事件。因此,更推荐像下面这样提供一个值为空的禁用选项。
    
    ```html
    <div id="example-6">
      <select v-model="selected" multiple style="width: 50px;">
        <option>A</option>
        <option>B</option>
        <option>C</option>
      </select>
      <br>
      <span>Selected: {{ selected }}</span>
    </div>
    • option 用 v-for 渲染的动态选项:
    <select v-model="selected">
      <option v-for="option in options" v-bind:value="option.value">
        {{ option.text }}
      </option>
    </select>
    <span>Selected: {{ selected }}</span>
    new Vue({
      el: '...',
      data: {
        selected: 'A',
        options: [
          { text: 'One', value: 'A' },
          { text: 'Two', value: 'B' },
          { text: 'Three', value: 'C' }
        ]
      }
    })
    • 使用动态 property

    有时我们可能想把值绑定到 Vue 实例的一个动态 property 上,这时可以用 v-bind 实现,并且这个 property 的值可以不是字符串。

    • 单选按钮
    <input type="radio" v-model="pick" v-bind:value="a">

    选中时 vm.pick == vm.a

    • 复选框
    <input
      type="checkbox"
      v-model="toggle"
      true-value="yes"
      false-value="no"
    >
    

    这里的 true-value 和 false-value attribute 并不会影响输入控件的 value attribute,因为浏览器在提交表单时并不会包含未被选中的复选框。如果要确保表单中这两个值中的一个能够被提交,(即“yes”或“no”),请换用单选按钮。

    • 选择框的选项
    <select v-model="selected">
      <!-- 内联对象字面量 -->
      <option v-bind:value="{ number: 123 }">123</option>
    </select>
      // 当选中时
    typeof vm.selected // => 'object'
    vm.selected.number // => 123
    • 修饰符

      • lazy
      <!-- 在“change”时而非“input”时更新 -->
      <input v-model.lazy="msg">
      • number
      <!--自动将用户的输入值转为数值类型,可以给 v-model 添加 number 修饰符:-->
      <input v-model.number="age" type="number">
      • trim
      <!--自动过滤用户输入的首尾空白字符-->
      <input v-model.trim="msg">
    • 在组件上使用 v-model

    创建一个custom-input组件,注意其中的

    Vue.component('custom-input', {
      props: ['value'],
      template: `
        <input
          v-bind:value="value"
          v-on:input="$emit('input', $event.target.value)"
        >
      `
    })

    现在 v-model 就应该可以在这个组件上完美地工作起来了:

    <custom-input v-model="searchText"></custom-input>
    • 通过插槽分发内容

    创建一个自定义一个插槽组件,注意 <slot>元素

    Vue.component('alert-box', {
      template: `
        <div class="demo-alert-box">
          <strong>Error!</strong>
          <slot></slot>
        </div>
      `
    })

    用法:

    <alert-box>
      Something bad happened.
    </alert-box>

    处会被插入的文字替换

    • 动态组件 (@todo)
    <!-- 组件会在 `currentTabComponent` 改变时改变 -->
    <component v-bind:is="currentTabComponent"></component>

    参考代码:https://hi.cellmean.com/p/a11cde485cc1

    • 解析dom模板时特殊元素和限制

    有些 HTML 元素,诸如 <ul><ol><table><select>,对于哪些元素可以出现在其内部是有严格限制的。而有些元素,诸如 <li><tr><option>,只能出现在其它某些特定的元素内部。

    不能这样写,因为要能出现在 table 元素下的元素有限制

    <table>
      <blog-post-row></blog-post-row>
    </table>

    可以使用 is 替换

    <table>
      <tr is="blog-post-row"></tr>
    </table>

    需要注意的是如果我们从以下来源使用模板的话,这条限制是不存在的:

    • 字符串 (例如:template: '...')

    • 单文件组件 (.vue)

    • <script type="text/x-template">

    • 组件名大小写

    支持 kebab-case 和 PascalCase命名方式

    注意:直接在 DOM (即非字符串的模板) 中使用时只有 kebab-case 是有效的。

    • 组件注册

      • 全局注册,在任何新创建的 Vue 根实例 (new Vue) 及子组件中都可以使用
      Vue.component('my-component-name', {
      // ... 选项 ...
      })
      • 局部注册
      var ComponentA = { /* ... */ }

      实例或子组件使用时需要添加 components 属性

      new Vue({
        el: '#app',
        components: {
          'component-a': ComponentA,
          'component-b': ComponentB
        }
      })
      • 模块系统中局部注册
      import ComponentA from './ComponentA'
      import ComponentC from './ComponentC'
      
      export default {
        components: {
          ComponentA,
          ComponentC
        },
        // ...
      }
      • 基础组件的自动化全局注册 (@todo)

      需要 webpack (或在内部使用了 webpack 的 Vue CLI 3+) 支持

    • Prop 的大小写 (camelCase vs kebab-case)

    如果在prop中使用 camelCase

    Vue.component('blog-post', {
      // 在 JavaScript 中是 camelCase 的
      props: ['postTitle'],
      template: '<h3>{{ postTitle }}</h3>'
    })

    在HTML中必须改成kebab-case ,

    <!-- 在 HTML 中是 kebab-case 的 -->
    <blog-post post-title="hello!"></blog-post>

    如果你使用字符串模板,那么这个限制就不存在了。

    • prop类型

    可以使用对象形式的写法指定名称和类型

      props: {
        title: String,
        likes: Number,
        isPublished: Boolean,
        commentIds: Array,
        author: Object,
        callback: Function,
        contactsPromise: Promise // or any other constructor
      }
    • 传递静态或动态 Prop

    静态:

    作为字符串传入

    <blog-post title="My journey with Vue"></blog-post>

    注意:这里的Prop posTitle,在html页使用时会转成 post-title, 除非在 字符串模板 使用才没有这种限制。

    
    Vue.component('blog-post', {
      // 在 JavaScript 中是 camelCase 的
      props: ['postTitle'],
      template: '<h3>{{ postTitle }}</h3>'
    })
    <blog-post post-title="hello!"></blog-post>

    Vue的字符串模板指的是在Vue实例中的template属性所对应的字符串

    动态:

    
    <!-- 动态赋予一个变量的值 -->
    <blog-post v-bind:title="post.title"></blog-post>
    
    <!-- 动态赋予一个复杂表达式的值 -->
    <blog-post
      v-bind:title="post.title + ' by ' + post.author.name"
    ></blog-post>
    • 传入一个数字
     <!-- 即便 `42` 是静态的,我们仍然需要 `v-bind` 来告诉 Vue -->
     <!-- 这是一个 JavaScript 表达式而不是一个字符串。-->
     <blog-post v-bind:likes="42"></blog-post>
    • 传入一个布尔值
    <!-- 包含该 prop 没有值的情况在内,都意味着 `true`。-->
    <blog-post is-published></blog-post>
    
    <!-- 即便 `false` 是静态的,我们仍然需要 `v-bind` 来告诉 Vue -->
    <!-- 这是一个 JavaScript 表达式而不是一个字符串。-->
    <blog-post v-bind:is-published="false"></blog-post>
    
    <!-- 用一个变量进行动态赋值。-->
    <blog-post v-bind:is-published="post.isPublished"></blog-post>
    • 传入一个对象的 所有 property

    可以使用不带参数的 v-bind (取代 v-bind:prop-name)。例如,对于一个给定的对象 post:

    <blog-post v-bind="post"></blog-post>

    等价于

    <blog-post
      v-bind:id="post.id"
      v-bind:title="post.title"
    ></blog-post>
    • 单向数据流

    所有的 prop 都使得其父子 prop 之间形成了一个单向下行绑定:父级 prop 的更新会向下流动到子组件中,但是反过来则不行。这样会防止从子组件意外变更父级组件的状态,从而导致你的应用的数据流向难以理解。

    额外的,每次父级组件发生变更时,子组件中所有的 prop 都将会刷新为最新的值。这意味着你不应该在一个子组件内部改变 prop。如果你这样做了,Vue 会在浏览器的控制台中发出警告。

    注意在 JavaScript 中对象和数组是通过引用传入的,所以对于一个数组或对象类型的 prop 来说,在子组件中改变变更这个对象或数组本身将会影响到父组件的状态。

    • Prop 验证

    为了定制 prop 的验证方式,你可以为 props 中的值提供一个带有验证需求的对象,而不是一个字符串数组。例如:

    Vue.component('my-component', {
      props: {
        // 基础的类型检查 (`null` 和 `undefined` 会通过任何类型验证)
        propA: Number,
        // 多个可能的类型
        propB: [String, Number],
        // 必填的字符串
        propC: {
          type: String,
          required: true
        },
        // 带有默认值的数字
        propD: {
          type: Number,
          default: 100
        },
        // 带有默认值的对象
        propE: {
          type: Object,
          // 对象或数组默认值必须从一个工厂函数获取
          default: function () {
            return { message: 'hello' }
          }
        },
        // 自定义验证函数
        propF: {
          validator: function (value) {
            // 这个值必须匹配下列字符串中的一个
            return ['success', 'warning', 'danger'].indexOf(value) !== -1
          }
        }
      }
    })

    注意那些 prop 会在一个组件实例创建之前进行验证,所以实例的 property (如 data、computed 等) 在 default 或 validator 函数中是不可用的。

    当验证失败时,(开发环境构建版本的) Vue 将会产生一个控制台的警告。

    • 非 Prop 的 Attribute

    如父级这样调用组件:

    <bootstrap-date-input data-date-picker="activated"></bootstrap-date-input>

    这里的 data-date-picker属性不是一个prop,而是attribute时,这样写之后这个属性会添加到组件的根元素上。

    • 替换/合并已有的 Attribute

    对于绝大多数 attribute 来说,从外部提供给组件的值会替换掉组件内部设置好的值。所以如果传入 type="text" 就会替换掉 type="date" 并把它破坏!庆幸的是,class 和 style attribute 会稍微智能一些,即两边的值会被合并起来,从而得到最终的值:

    • 禁用 Attribute 继承

    如果你不希望组件的根元素继承 attribute,你可以在组件的选项中设置 inheritAttrs: false

    注意 inheritAttrs: false 选项不会影响 style 和 class 的绑定。

    • $attrs property 与 inheritAttrs

    该 property 包含了传递给一个组件的 attribute 名和 attribute 值,例如:

    {
      required: true,
      placeholder: 'Enter your username'
    }

    配合 inheritAttrs: false 使用

    Vue.component('base-input', {
      inheritAttrs: false,
      props: ['label', 'value'],
      template: `
        <label>
          {{ label }}
          <input
            v-bind="$attrs"
            v-bind:value="value"
            v-on:input="$emit('input', $event.target.value)"
          >
        </label>
      `
    })

    调用 :

    <base-input
      v-model="username"
      required
      placeholder="Enter your username"
    ></base-input>

    这个模式允许你在使用基础组件的时候更像是使用原始的 HTML 元素,而不会担心哪个元素是真正的根元素:

    Day 11

    2020.08.15

    • 自定义组件的 v-model
    Vue.component('base-checkbox', {
      model: {
        prop: 'checked',
        event: 'change'
      },
      props: {
        checked: Boolean
      },
      template: `
        <input
          type="checkbox"
          v-bind:checked="checked"
          v-on:change="$emit('change', $event.target.checked)"
        >
      `
    })

    用法:

    <base-checkbox v-model="lovingVue"></base-checkbox>
    • 将原生事件绑定到组件 你可能有很多次想要在一个组件的根元素上直接监听一个原生事件。这时,你可以使用 v-on 的 .native 修饰符
    <base-input v-on:focus.native="onFocus"></base-input>

    vue 提供了一个 $listeners property,它是一个对象,里面包含了作用在这个组件上的所有监听器。例如:

    {
      focus: function (event) { /* ... */ }
      input: function (value) { /* ... */ },
    }

    有了这个 $listeners property,你就可以配合 v-on="$listeners" 将所有的事件监听器指向这个组件的某个特定的子元素。

    • .sync 修饰符

    我们推荐以 update:myPropName 的模式触发事件

    子组件触发事件 :

    this.$emit('update:title', newTitle)

    父组件监听事件并触发更新

    <text-document
      v-bind:title="doc.title"
      v-on:update:title="doc.title = $event"
    ></text-document>

    这种模式可以简写成

    <text-document v-bind:title.sync="doc.title"></text-document>

    将 v-bind.sync 用在一个字面量的对象上,例如 v-bind.sync=”{ title: doc.title }”,是无法正常工作的,因为在解析一个像这样的复杂表达式的时候,有很多边缘情况需要考虑

    下面这样会把 doc 对象中的每一个 property (如 title) 都作为一个独立的 prop 传进去,然后各自添加用于更新的 v-on 监听器。

    <text-document v-bind.sync="doc"></text-document>

    将 v-bind.sync 用在一个字面量的对象上,例如 v-bind.sync=”{ title: doc.title }”,是无法正常工作的,因为在解析一个像这样的复杂表达式的时候,有很多边缘情况需要考虑

    • 插槽编译作用域
    <navigation-link url="/profile">
      Clicking here will send you to: {{ url }}  
    </navigation-link>

    如果url是插槽内部 <navigation-link> 的属性变量,外面是访问不到的,这里会显示 undefined

    • 插槽后备内容

    如在一个 submit-button的组件中

    <button type="submit">
      <slot>Submit</slot>
    </button>

    调用时不带内容

    <submit-button></submit-button>

    渲染结果:

    <button type="submit">
      Submit
    </button>
    • 具名插槽

    <slot> 元素有一个特殊的 attribute:name。这个 attribute 可以用来定义额外的插槽:

    <div class="container">
      <header>
        <slot name="header"></slot>
      </header>
      <main>
        <slot></slot>
      </main>
      <footer>
        <slot name="footer"></slot>
      </footer>
    </div>

    一个不带 name 的 <slot> 出口会带有隐含的名字 “default”。

    在向具名插槽提供内容的时候,我们可以在一个 <template> 元素上使用 v-slot 指令,并以 v-slot 的参数的形式提供其名称

    <base-layout>
      <template v-slot:header>
        <h1>Here might be a page title</h1>
      </template>
    
      <p>A paragraph for the main content.</p>
      <p>And another one.</p>
    
      <template v-slot:footer>
        <p>Here's some contact info</p>
      </template>
    </base-layout>

    最终渲染为:

    <div class="container">
      <header>
        <h1>Here might be a page title</h1>
      </header>
      <main>
        <p>A paragraph for the main content.</p>
        <p>And another one.</p>
      </main>
      <footer>
        <p>Here's some contact info</p>
      </footer>
    </div>

    注意 v-slot 只能添加在 <template>

    在动态组件上使用 keep-alive

    动态切换组件时 如:

    <component v-bind:is="currentTabComponent"></component>

    重新切换到原来的组件,会重新创建组件,原来组件的状态会丢失,可以使用 <keep-alive>标签缓存原来组件

    <!-- 失活的组件将会被缓存!-->
    <keep-alive>
      <component v-bind:is="currentTabComponent"></component>
    </keep-alive>

    演示代码(多标签切换恢复时保持原组件状态)

    • 异步组件

    Vue 允许你以一个工厂函数的方式定义你的组件,这个工厂函数会异步解析你的组件定义。Vue 只有在这个组件需要被渲染的时候才会触发该工厂函数,且会把结果缓存起来供未来重渲染。例如:

    Vue.component('async-example', function (resolve, reject) {
      setTimeout(function () {
        // 向 `resolve` 回调传递组件定义
        resolve({
          template: '<div>I am async!</div>'
        })
      }, 1000)
    })
    • 异步加载组件

    一个推荐的做法是将异步组件和 webpack 的 code-splitting 功能一起配合使用,参考使用了 vuex 插件的 路由加载 About 的方式 这段特殊注释不是多余的 : /* webpackChunkName: "about" */

      {
        path: '/about',
        name: 'About',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
      }
    • 异步加载时处理加载状态

    这里的异步组件工厂函数也可以返回一个如下格式的对象:

    const AsyncComponent = () => ({
      // 需要加载的组件 (应该是一个 `Promise` 对象)
      component: import('./MyComponent.vue'),
      // 异步组件加载时使用的组件
      loading: LoadingComponent,
      // 加载失败时使用的组件
      error: ErrorComponent,
      // 展示加载时组件的延时时间。默认值是 200 (毫秒)
      delay: 200,
      // 如果提供了超时时间且组件加载也超时了,
      // 则使用加载失败时使用的组件。默认值是:`Infinity`
      timeout: 3000
    })

    day12

    2020.08.18

    • 访问根实例

    子组件可以通过$root 属性访问根实例

    // 获取根组件的数据
    this.$root.foo
    
    // 写入根组件的数据
    this.$root.foo = 2
    
    // 访问根组件的计算属性
    this.$root.bar
    
    // 调用根组件的方法
    this.$root.baz()

    在绝大多数情况下,推荐使用 Vuex 来管理应用的状态。

    day13

    2020.08.20

    • 访问父级组件实例

    一个google地图的例子

    • 访问子组件实例或子元素

    如果需要在javascript直接访问子组件时,可以在使用子组件时加入 ref 属性,如:

    <base-input ref="usernameInput"></base-input>

    可以使用 this.$refs.usernameInput 来访问这个 <base-input> 实例

    • 依赖注入

    在父级元素中提供 provide

    provide: function () {
      return {
        getMap: this.getMap
      }
    }

    在子元素实例使用 inject 接收指定的我们想要添加在这个实例上的 property:

    inject: ['getMap']

    依赖注入的google map实例

    依赖注入所提供的 property 是非响应式的,你想要共享的这个 property 是你的应用特有的,而不是通用化的,或者如果你想在祖先组件中更新所提供的数据,那么这意味着你可能需要换用一个像 Vuex 这样真正的状态管理方案了。

    • 程序化的事件侦听器 (@todo)
    • 通过 $on(eventName, eventHandler) 侦听一个事件
    • 通过 $once(eventName, eventHandler) 一次性侦听一个事件
    • 通过 $off(eventName, eventHandler) 停止侦听一个事件

    日期选择器实例

    • 递归组件

    组件是可以在它们自己的模板中调用自身的。不过它们只能通过 name 选项来做这件事:

    name: 'stack-overflow',
    template: '<div><stack-overflow></stack-overflow></div>'

    类似上述的组件将会导致“max stack size exceeded”错误,所以请确保递归调用是条件性的 (例如使用一个最终会得到 false 的 v-if)。

    • 组件之间的循环引用

    我们先把两个组件称为 A 和 B。模块系统发现它需要 A,但是首先 A 依赖 B,但是 B 又依赖 A,但是 A 又依赖 B,如此往复。这变成了一个循环,不知道如何不经过其中一个组件而完全解析出另一个组件。为了解决这个问题,我们需要给模块系统一个点,在那里“A 反正是需要 B 的,但是我们不需要先解析 B。”

    <tree-folder> 组件设为了那个点。我们知道那个产生悖论的子组件是 <tree-folder-contents> 组件,所以我们会等到生命周期钩子 beforeCreate 时去注册它:

    beforeCreate: function () {
      this.$options.components.TreeFolderContents = require('./tree-folder-contents.vue').default
    }

    或者 webpack 异步 import

    components: {
      TreeFolderContents: () => import('./tree-folder-contents.vue')
    }
    • 内联模板

    inline-template 属性,内联模板需要定义在 Vue 所属的 DOM 元素内。

    <my-component inline-template>
      <div>
        <p>These are compiled as the component's own template.</p>
        <p>Not parent's transclusion content.</p>
      </div>
    </my-component>
    • X-Template

    x-template 需要定义在 Vue 所属的 DOM 元素外。

    <script type="text/x-template" id="hello-world-template">
      <p>Hello hello hello</p>
    </script>
    
    Vue.component('hello-world', {
      template: '#hello-world-template'
    })
    
    • 通过 v-once 创建低开销的静态组件

    有的时候你可能有一个组件,这个组件包含了大量静态内容。在这种情况下,可以在根元素上添加 v-once attribute 以确保这些内容只计算一次然后缓存起来

    Vue.component('terms-of-service', {
      template: `
        <div v-once>
          <h1>Terms of Service</h1>
          ... a lot of static content ...
        </div>
      `
    })

    过渡 & 动画(@todo)

    Vue 在插入、更新或者移除 DOM 时,提供多种不同方式的应用过渡效果。

    • 在 CSS 过渡和动画中自动应用 class
    • 可以配合使用第三方 CSS 动画库,如 Animate.css
    • 在过渡钩子函数中使用 JavaScript 直接操作 DOM
    • 可以配合使用第三方 JavaScript 动画库,如 Velocity.js

    vue router

    官方文档

    免费课程

    day15

    2020.08.25

    一个 materialize UI类库

    Firebase

    当前建立的firebase项目为 udemy-ninja-smoothies

    firebase api信息

     // Your web app's Firebase configuration
      var firebaseConfig = {
        apiKey: "AIzaSyAY6uN7BCWS4licC7Yeyn_i9qE6Ceji-rs",
        authDomain: "udemy-ninja-smoothies-fab0d.firebaseapp.com",
        databaseURL: "https://udemy-ninja-smoothies-fab0d.firebaseio.com",
        projectId: "udemy-ninja-smoothies-fab0d",
        storageBucket: "udemy-ninja-smoothies-fab0d.appspot.com",
        messagingSenderId: "968931780652",
        appId: "1:968931780652:web:6678a7f3690b7d6330c989",
        measurementId: "G-K0S8B25CWF"
      };
      // Initialize Firebase
      firebase.initializeApp(firebaseConfig);
      firebase.analytics();

    vue 整合firebase /firestore

    day16

    2020.08.27

    使用预处理器

    部署到firebase

    • 安装 Firebase CLI
    npm install -g firebase-tools
    • 初始化您的项目

    请打开终端窗口,转到 Web 应用的根目录,或为 Web 应用创建根目录

    登录 Google

    firebase login

    启动项目 从该应用的根目录中运行此命令:

    firebase init
    • npm run build

    • 部署到 Firebase 托管

    firebase deploy

    Project Console: https://console.firebase.google.com/project/udemy-ninja-smoothies-fab0d/overview

    Hosting URL: https://udemy-ninja-smoothies-fab0d.web.app

    day17

    2020.08.29-2020.08.30

    Firebase两种类型数据库比较

    js时间日期处理库

    vue-chat-scroll插件

    新内容添加时自动滚动到元素最底端,如聊天记录,用法

    import Vue from 'vue'
     
    import VueChatScroll from 'vue-chat-scroll'
    Vue.use(VueChatScroll)

    day18

    2020.08.31

    Firebase控制台

    google apis console(包括google map)

    创建 google map API密钥

    • 打开google apis console,导航处选择对应的项目。
    • 点击 ENABLE APIS AND SERVICES按钮,搜索或点击 Maps JavaScript API的方块,在出现的按钮点击启用
    • 启用后会跳转到报表页,这时点击页眉的抽屉导航,在菜单中 选择API与服务 > 凭据 ,在出现的右上方标签位置点 +创建凭据 ,选择API密钥

    弹出图层:

    在您的应用中使用此密钥的方法是 key=API_KEY 参数传递此密钥
    
    AIzaSyBSaj2YcxYDzAnGV_OomO5CCMkj9-HRC1k
    您的 API 密钥

    引入:

    <script defer
      src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
    </script>

    相关用法和文档 https://cloud.google.com/maps-platform

    粘贴上传文件

    原理及简单示例

    应用在vue,请忽略作者的中式英语

    text-field-edit

    • it doesn't break the undo history (in supported browsers)
    • it fires an input event (with event.inputType === 'insertText')
    • it's the most efficient way of adding/replacing selected text in a field
    • it's cross-browser (modern browsers)

    fineuploader

    很遗憾,作者不再维护了。

    uppy文件上传

    可替代 fineuploader

GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: <program> Copyright (C) <year> <name of author> This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.

简介

我学习vue和firebase的笔记和练习代码 展开 收起
JavaScript
GPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/falcon/vue-firebase-study.git
git@gitee.com:falcon/vue-firebase-study.git
falcon
vue-firebase-study
vue-firebase-study
master

搜索帮助