Vue --第四天

1.自定义指令

a.自定义指令:

自己定义的指令,可以封装一些dom 操作,扩展额外功能

全局注册:

局部注册:

指令值:自定义指令

v-loading:

本质:

插槽:

1.定制插槽

2.插槽作用

组件封装:涵盖了以上所有的知识点

1.失去焦点  : @blur="  判定条件  "

2.得到当前动作的值: e.target.value

代码:在插槽拼接

路由:

使用步骤:(5+2)

实现:

这里很奇怪,为什么组件要有如下配置

使用总结:

路由和组件分类:

代码:

import Vue from 'vue'

import App from './App.vue'

// 路由的使用步骤 5 + 2

// 5个基础步骤

// 1. 下载 v3.6.5

// 2. 引入

// 3. 安装注册 Vue.use(Vue插件)

// 4. 创建路由对象

// 5. 注入到new Vue中,建立关联

// 2个核心步骤

// 1. 建组件(views目录),配规则

// 2. 准备导航链接,配置路由出口(匹配的组件展示的位置)

import Find from './views/Find'

import My from './views/My'

import Friend from './views/Friend'

import VueRouter from 'vue-router'

Vue.use(VueRouter) // VueRouter插件初始化


 

const router = new VueRouter({

  // routes 路由规则们

  // route  一条路由规则 { path: 路径, component: 组件 }

  routes: [

    { path: '/find', component: Find },

    { path: '/my', component: My },

    { path: '/friend', component: Friend },

  ]

})

Vue.config.productionTip = false

new Vue({

  render: h => h(App),

  router:router,

}).$mount('#app')

<template>

  <div>

    <div class="footer_wrap">

      <a href="#/find">发现音乐</a>

      <a href="#/my">我的音乐</a>

      <a href="#/friend">朋友</a>

    </div>

    <div class="top">

      <!-- 这个是路由内容展现所在的位置,用router-view -->

      <router-view></router-view>

    </div>

  </div>

</template>

<script>

export default {};

</script>

<template>

  <div>

    <p>我的音乐</p>

    <p>我的音乐</p>

    <p>我的音乐</p>

    <p>我的音乐</p>

  </div>

</template>

<script>

export default {

  name: 'MyMusic'

}

</script>

相关推荐

  1. 开始学习

    2023-12-06 03:28:03       56 阅读
  2. 实习记录——

    2023-12-06 03:28:03       48 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-06 03:28:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-06 03:28:03       101 阅读
  3. 在Django里面运行非项目文件

    2023-12-06 03:28:03       82 阅读
  4. Python语言-面向对象

    2023-12-06 03:28:03       91 阅读

热门阅读

  1. 鼠标移入移出事件

    2023-12-06 03:28:03       58 阅读
  2. Gson与FastJson详解

    2023-12-06 03:28:03       53 阅读
  3. qt 5.15.2 网络文件下载功能

    2023-12-06 03:28:03       58 阅读
  4. 卷积神经网络训练情感分析

    2023-12-06 03:28:03       57 阅读
  5. 11-鸿蒙4.0学习之页面之间的参数传递

    2023-12-06 03:28:03       48 阅读
  6. RabbitMQ之ttl(过期消息)解读

    2023-12-06 03:28:03       56 阅读
  7. es常用查询编辑

    2023-12-06 03:28:03       48 阅读
  8. React-hook-form-mui (二):表单数据处理

    2023-12-06 03:28:03       52 阅读
  9. 零基础学Python的第六天||字符串(3)

    2023-12-06 03:28:03       61 阅读
  10. 从react到xflow

    2023-12-06 03:28:03       52 阅读