2020-08-22

44 篇文章 0 订阅
7 篇文章 0 订阅

Js是一个易于使用的Web应用程序框架,我们可以使用它开发交互式前端应用程序。在本文中,我们将了解添加旋转木马、警报、拖放和视频播放器的最佳包。

适用于Vue.js
SickforVue.js允许我们在Vue应用程序中添加一个旋转木马。

想系统学习前端web的朋友,欢迎私信奕辰获取免费学习教程。

1.评论文章,没字数限制,一个字都行! 2.关注奕辰,成为的粉丝! 3.私信奕辰:“web”,“1”获取前端学习面试资料。

大家一起学习(群主会不定时更新学习资料,以及面试题文档)

或者可以添加我的个人微信号:wdnmd__xxx

小助理微信:lyf___1201

为了使用它,我们运行:

npm i vue-slick

然后我们可以用它写:

<template>
  <div>
    <slick ref="slick" :options="slickOptions">
      <a href="http://placekitten.com/200/200">
        <img src="http://placekitten.com/200/200" alt>
      </a>
      <a href="http://placekitten.com/200/200">
        <img src="http://placekitten.com/200/200" alt>
      </a>
    </slick>
  </div>
</template>
 
<script>
import Slick from "vue-slick";
import "../../../node_modules/slick-carousel/slick/slick.css";export default {
  components: { Slick },  data() {
    return {
      slickOptions: {
        slidesToShow: 1
      }
    };
  },  methods: {
    next() {
      this.$refs.slick.next();
    },    prev() {
      this.$refs.slick.prev();
    },    reInit() {
      this.$nextTick(() => {
        this.$refs.slick.reSlick();
      });
    }
  }
};
我们使用slick组件来添加旋转木马。它有按钮。我们将其设置为每页显示一张幻灯片,slidesToShow选择。此外,我们导入样式使其正确显示。

Vue-甜警报器2
Vue-甜警报2允许我们在我们的应用程序中添加一个警报显示。

要安装它,我们运行:

npm i vue-sweetalert2

然后我们可以用它写:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueSweetalert2 from "vue-sweetalert2";
import "sweetalert2/dist/sweetalert2.min.css";Vue.use(VueSweetalert2);
Vue.config.productionTip = false;new Vue({
  render: h => h(App)
}).$mount("#app");
App.vue

<template>
  <button @click="showAlert">click me</button>
</template>
 
<script>
export default {
  methods: {
    showAlert() {
      this.$swal("Hello!");
    }
  }
};
我们使用$swal方法来创建我们自己的警报。我们可以更改按钮的颜色,也可以添加自定义样式。

为此,我们写道:

import Vue from "vue";
import App from "./App.vue";
import VueSweetalert2 from "vue-sweetalert2";
import "sweetalert2/dist/sweetalert2.min.css";const options = {
  confirmButtonColor: "green",
  cancelButtonColor: "blue"
};Vue.use(VueSweetalert2, options);
Vue.config.productionTip = false;new Vue({
  render: h => h(App)
}).$mount("#app");

我们用对象设置“确认”和“取消”按钮的颜色。

视频播放器
Vue-视频播放器是一个视频播放器组件,我们可以添加到一个Vue应用程序。

要安装它,我们运行:

npm i vue-video-player

然后我们可以用它写:

<template>
  <video-player
    class="video-player-box"
    ref="videoPlayer"
    :options="playerOptions"
    :playsinline="true"
  ></video-player>
</template>
 
<script>
export default {
  data() {
    return {
      playerOptions: {
        muted: true,
        language: "en",
        playbackRates: [0.7, 1.0, 1.5, 2.0],
        sources: [
          {
            type: "video/mp4",
            src:
              "https://mirrors.standaloneinstaller.com/video-sample/P6090053.mp4"
          }
        ],
        poster: "https://placekitten.com/200/200"
      }
    };
  },  computed: {
    player() {
      return this.$refs.videoPlayer.player;
    }
  },
  methods: {}
};
我们添加了video-player组件。我们刚开始src视频的位置。

poster我们在播放视频之前看到的图片。

video-player还会发出所有视频元素事件,如play , pause , canplay还有更多。

Vue-拖拽
Vue-拖放为我们提供组件,让我们在VUE应用程序中添加拖放功能。

要安装它,我们运行:

npm i vue-drag-drop

然后我们可以用它写:

main.js

import Vue from "vue";
import App from "./App.vue";
import { Drag, Drop } from "vue-drag-drop";Vue.component("drag", Drag);
Vue.component("drop", Drop);
Vue.config.productionTip = false;new Vue({
  render: h => h(App)
}).$mount("#app");
App.vue

<template>
  <div>
    <drag class="drag" :transfer-data="{ draggable }">{{ draggable }}</drag>
    <drop class="drop" @drop="handleDrop">Dropzone</drop>
  </div>
</template>
 
<script>
export default {
  data() {
    return { draggable: "Drag Me" };
  },
  methods: {
    handleDrop() {
      alert("dropped");
    }
  }
};
</script><style>
.drag,
.drop {
  display: inline-block;
  position: relative;
  padding: 30px;
  text-align: center;
  vertical-align: top;
}
我们有drag和drop组件来自库。我们可以拖动drag组件的drop组件。然后drop事件,并且handleDrop方法正在运行。

想系统学习前端web的朋友,欢迎私信奕辰获取免费学习教程。

1.评论文章,没字数限制,一个字都行! 2.关注奕辰,成为的粉丝! 3.私信奕辰:“web”,“1”获取前端学习面试资料。

大家一起学习(群主会不定时更新学习资料,以及面试题文档)

或者可以添加我的个人微信号:wdnmd__xxx

小助理微信:lyf___1201

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用 Java 中的 LocalDateTime 类来处理时间。 首先,我们需要将给定的时间段转换为 LocalDateTime 对象: ```java LocalDateTime start = LocalDateTime.of(2020, 11, 20, 0, 0, 0); LocalDateTime end = LocalDateTime.of(2021, 10, 9, 23, 59, 59); ``` 这里将结束时间设置为 23:59:59 是因为我们想要包含该日期的所有时间。 接下来,我们可以使用一个循环来遍历时间段中的每一天,并获取该天的开始时间和结束时间: ```java LocalDateTime current = start; while (!current.isAfter(end)) { LocalDateTime dayStart = current.withHour(0).withMinute(0).withSecond(0).withNano(0); LocalDateTime dayEnd = current.withHour(23).withMinute(59).withSecond(59).withNano(999999999); System.out.println("Day " + current.toLocalDate() + " starts at " + dayStart + " and ends at " + dayEnd); current = current.plusDays(1); } ``` 这里,我们使用 `withHour`、`withMinute`、`withSecond` 和 `withNano` 方法来设置每天的开始时间和结束时间。然后,我们可以使用 `plusDays` 方法来增加 `current` 对象的日期,以便遍历整个时间段。 完整代码如下: ```java import java.time.LocalDateTime; public class Main { public static void main(String[] args) { LocalDateTime start = LocalDateTime.of(2020, 11, 20, 0, 0, 0); LocalDateTime end = LocalDateTime.of(2021, 10, 9, 23, 59, 59); LocalDateTime current = start; while (!current.isAfter(end)) { LocalDateTime dayStart = current.withHour(0).withMinute(0).withSecond(0).withNano(0); LocalDateTime dayEnd = current.withHour(23).withMinute(59).withSecond(59).withNano(999999999); System.out.println("Day " + current.toLocalDate() + " starts at " + dayStart + " and ends at " + dayEnd); current = current.plusDays(1); } } } ``` 输出结果如下: ``` Day 2020-11-20 starts at 2020-11-20T00:00 and ends at 2020-11-20T23:59:59.999999999 Day 2020-11-21 starts at 2020-11-21T00:00 and ends at 2020-11-21T23:59:59.999999999 Day 2020-11-22 starts at 2020-11-22T00:00 and ends at 2020-11-22T23:59:59.999999999 ... Day 2021-10-07 starts at 2021-10-07T00:00 and ends at 2021-10-07T23:59:59.999999999 Day 2021-10-08 starts at 2021-10-08T00:00 and ends at 2021-10-08T23:59:59.999999999 Day 2021-10-09 starts at 2021-10-09T00:00 and ends at 2021-10-09T23:59:59.999999999 ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值