当前位置: 首页 > news >正文

郑州上海做网站的公司手机网站建设案例

郑州上海做网站的公司,手机网站建设案例,莱芜网络公司平台,在线做网站大概多少钱一、proxy方式 1.封装日期选择工具函数: 在untils文件夹下新建index.ts,并导出工具函数 /*** 获取不同类型日期* param:类型 dateVal: 是否指定*/ export function getSystemDate(param: any, dateVal: any) {let systemDate dateVal ? new Date(da…

一、proxy方式

1.封装日期选择工具函数:

在untils文件夹下新建index.ts,并导出工具函数

/*** 获取不同类型日期* param:类型 dateVal: 是否指定*/
export function getSystemDate(param: any, dateVal: any) {let systemDate = dateVal ? new Date(dateVal) : new Date(),year = systemDate.getFullYear(),month = systemDate.getMonth() + 1,date = systemDate.getDate(),hours = systemDate.getHours(),minutes = systemDate.getMinutes(),seconds = systemDate.getDate(),milliseconds = systemDate.getMilliseconds();month = month < 10 ? "0" + month : month;date = date < 10 ? "0" + date : date;hours = hours < 10 ? "0" + hours : hours;minutes = minutes < 10 ? "0" + minutes : minutes;seconds = seconds < 10 ? "0" + seconds : seconds;if (param == 0) {return year + "-" + month + "-" + date;} else if (param == 1) {return year + "-" + month + "-" + date + " " + hours + ":" + minutes + ":" + seconds;} else if (param == 2) {return year + "-" + month + "-" + date + " " + hours + ":" + minutes + ":" + seconds + "." + milliseconds;} else if (param == 3) {return year + "-" + month;} else if (param == 4) {return year;}
}

2.引入并挂载到全局

在main.ts中,引入后挂载

import { App, createApp } from "vue";
import App from "./App.vue";import { getSystemDate } from "@/utils/index"; //引入全局使用的方法const app = createApp(App);app.config.globalProperties.$getSystemDate = getSystemDate; //挂载到全局app.mount("#app");

注意:

        1.vue3中挂载实例要用app.config.globalProperties.$方法,而vue2中挂载实例是Vue.prototype.$方法;

3.在页面中按需调用

template部分代码:

<template><div><el-date-pickerv-model="plantInfo.gridDate"type="date"placeholder="选择日期":disabled-date="disabledDate":shortcuts="shortcuts"format="YYYY-MM-DD"style="width: 100%"/></div>
</template>

script 中代码:

<script setup lang="ts" name="site">
import { ref, reactive, getCurrentInstance } from "vue";// proxy相当于 vue2的this,从getCurrentInstance 实例中获取,proxy对象
const { proxy } = getCurrentInstance();interface PlantInfo {plantName: any;plantScale: any;sysuserid: any;userDepid: any;gridDate: any;plantNetType: any;voltageLevel: any;prjAddr: any;longitude: any;moduleManufacturer: any;componentBrand: any;componentModel: any;workHours: any;plantStatus: any;roofPitch: any;orientation: any;plantShip: any;plantType: any;streetAddress: any;plantSummary: any;plantImageUrl: any;plantInvestor: any;
}const plantInfo = ref<PlantInfo>({plantName: "",plantScale: "",sysuserid: "",userDepid: "",gridDate: proxy.$getSystemDate(0),plantNetType: "",voltageLevel: "",prjAddr: "",longitude: "",moduleManufacturer: "",componentBrand: "",componentModel: "",workHours: "",plantStatus: "",roofPitch: "",orientation: "",plantShip: "",plantType: "",streetAddress: "",plantSummary: "",plantImageUrl: "",plantInvestor: ""
});const disabledDate = (time: Date) => {return time.getTime() > Date.now();
};
// 快速日期选择属性
const shortcuts = [{text: "今天",value: new Date()},{text: "昨天",value: () => {const date = new Date();date.setTime(date.getTime() - 3600 * 1000 * 24);return date;}},{text: "一周前",value: () => {const date = new Date();date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);return date;}}
];
</script>

二、provide方式

        在Vue 3 + TypeScript 中挂载并使用一个全局的工具函数,你可以通过 Vue 实例的 provide 和 inject 方法来实现。具体步骤如下:

1.创建工具函数: 首先,创建你的工具函数。

// utils.ts
export function myUtilityFunction(): void {// Your utility function logic here
}

2.在主入口文件中挂载工具函数: 在 Vue 的主入口文件中,将工具函数通过 provide 方法挂载到全局。

// main.ts
import { createApp } from 'vue';
import App from './App.vue';
import { myUtilityFunction } from './utils';const app = createApp(App);// 将工具函数挂载到全局
app.provide('myUtility', myUtilityFunction);app.mount('#app');

3.在组件中使用工具函数: 在需要使用工具函数的组件中,通过 inject 方法注入并使用该函数。

<!-- MyComponent.vue -->
<template><div><button @click="useUtility">使用工具函数</button></div>
</template><script lang="ts">
import { defineComponent, inject } from 'vue';export default defineComponent({setup() {// 注入工具函数const myUtility = inject<() => void>('myUtility');const useUtility = () => {// 使用工具函数myUtility();};return {useUtility};}
});
</script>

http://www.15wanjia.com/news/53802.html

相关文章:

  • 我的网站怎么不能搜索网页入口网站推广
  • 高端网站建设设计公司哪家好百度网页版怎么切换
  • 小程序网站建设数据分析软件哪个最好用
  • 网站接口需求网站建设多少钱
  • 网站建设公司平台企业老板培训课程
  • 微信商城网站优化大师哪个好
  • 怎么查网址是不是诈骗网站百度问一问官网
  • 网站建设运用软件成都竞价托管多少钱
  • iis7.5 网站配置百度号码认证平台官网首页
  • 做个自己的影院网站怎么做冯耀宗seo课程
  • 本地的南通网站建设乐陵seo优化
  • 企业宣传册范例优化营商环境的金句
  • 做网站推广优化靠谱外链推广
  • 迅速百度网站自然排名营销神器
  • 做网站的法律网络黄页推广软件
  • 延边州网站建设网站搭建工具
  • 宝安附近公司做网站建设多少钱网络营销题库案例题
  • 免费做链接的网站宁波seo关键词优化
  • 学做网站论坛好吗品牌关键词优化哪家便宜
  • 企业网站flash动画百度联盟个人怎么接广告
  • 象山企业门户网站建设网站优化是什么
  • 自己网站制作的详细教程搜索引擎广告形式有哪些
  • 世界各大网站搜索引擎提交入口做营销型网站哪家好
  • 内网网站开发报价百度上怎么注册店铺地址
  • 开发公司安全工作总结汇报seo指的是什么意思
  • 美容类 营销型网站某个产品营销推广方案
  • 响应式网站用什么单位网络整合营销4i原则
  • 做跨境电商的血泪教训宁波seo网站服务
  • 网站logo在哪里修改商务软文写作300字
  • 做企业网站建设挣钱吗seo入门基础知识