中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

做美團網(wǎng)這種網(wǎng)站賺錢嗎亞馬遜關(guān)鍵詞搜索器

做美團網(wǎng)這種網(wǎng)站賺錢嗎,亞馬遜關(guān)鍵詞搜索器,室內(nèi)設(shè)計聯(lián)盟免費下載,小門店做網(wǎng)站一、需求說明 在項目中 點擊按鈕 復制 某行文本是很常見的 應(yīng)用場景, 在 Vue 項目中實現(xiàn) 復制功能 需要借助 vue-clipboard2 插件。 二、代碼實現(xiàn) 1、安裝 vue-clipboard2 依賴 ( 出現(xiàn)錯誤的話,可以試試切換成淘寶鏡像源 npm config set r…

一、需求說明
在項目中 點擊按鈕 復制 某行文本是很常見的 應(yīng)用場景,

在 Vue 項目中實現(xiàn) 復制功能 需要借助 vue-clipboard2 插件。

二、代碼實現(xiàn)
1、安裝 vue-clipboard2 依賴
( 出現(xiàn)錯誤的話,可以試試切換成淘寶鏡像源

npm config set registry https://registry.npm.taobao.org )

npm install --save vue-clipboard2

2、在 main.js 文件中全局引入插件
示例代碼如下:

import Vue from 'vue'
import VueClipBoard from 'vue-clipboard2'
?
Vue.use(VueClipBoard)
?
new Vue({
? render: h => h(App)
}).$mount('#app')

3、案例

在組件中有兩種方法可以實現(xiàn)復制功能。

方法一?:

使用?vue-clipboard2?提供的 指令

直接將變量內(nèi)容復制至剪切板,暫時沒有找到處理數(shù)據(jù)后再復制的方式

<template>
? <div class="yeluosen">
? ? <input type="text" v-model="message">
? ? <el-button?
? ? ? icon="el-icon-share"?
? ? ? size="mini"?
? ? ? style="font-size: 16px;padding: 4px 8px;"?
? ? ? title="共享"?
? ? ? v-clipboard:copy="scope.row.url"?
? ? ? v-clipboard:success="onCopy"?
? ? ? v-clipboard:error="onError"?
? ? ? @click="share(scope.row.url)"></el-button>
? </div>
</template>

復制時,通過 v-clipboard: copy 復制輸入的內(nèi)容 :

// 復制成功 or 失敗(提示信息!!!)
onCopy: function (e) {
? console.log('復制成功!', e)
},
onError: function (e) {
? console.log('復制失敗!', e)
}

方法二:
使用?vue-clipboard2?全局綁定的?$copyText?事件方法

復制動作使用的是 Vue?響應(yīng)函數(shù)方式,這就為復制前控制數(shù)據(jù)提供了可能!

// 點擊事件
share(val) {
? this.handleData(val)
? this.$copyText(this.message).then(function (e) {
? ? alert('Copied')
? }, function (e) {
? ? alert('Can not copy')
? })
},
?
// 數(shù)據(jù)處理
handleData(val){
? this.message = this.message + ' ' + val
}

<template>
? <div>
? ? <el-button
? ? ? type="success"
? ? ? size="small"
? ? ? style="margin-left: 10px"
? ? ? @click="onCopy"
? ? ? >復制</el-button
? ? >
? </div>
</template>
?
<script>
export default {
? data() {
? ? return {
? ? ? text: "這是一段復制的文本",
? ? };
? },
? methods: {
? ? onCopy() {
? ? ? this.$copyText(this.pathText).then(
?? ? ? ? ?e=>{
?? ? ? ? ? ?console.log('復制成功:', e);
?? ? ? ? ?},
?? ? ? ? ?e=>{
?? ? ? ? ? ?console.log('復制失敗:', e);
?? ? ? ? ?}
? ? ? )
? ? }
? }
};
</script>

三、項目所用

實現(xiàn)選中并且復制成功后帶有提示信息的效果 :

<template>
? <div>
? ? <el-input ref="addressInput" v-model="address" :readonly="true">
? ? ? <template slot="prepend"> 反饋地址 </template>
? ? </el-input>
? ? <el-button @click="copyLink(address)">復制鏈接</el-button>
? </div>
</template>
?
<script>
export default {
? data() {
? ? return {
? ? ? address: "https://www.baidu.com/", // 地址信息
? ? };
? },
? methods: {
? ? // 判斷是否是 IE 瀏覽器
? ? isIE() {
? ? ? if (window.ActiveXObject || "ActiveXObject" in window) {
? ? ? ? return true;
? ? ? } else {
? ? ? ? return false;
? ? ? }
? ? },
? ? // 拷貝地址
? ? copyLink(url) {
? ? ? if (this.isIE()) {
? ? ? ? this.$copyText(url);
? ? ? ? this.$refs.addressInput.select(); // 實現(xiàn)選中效果
? ? ? ? this.$message.success("復制成功!");
? ? ? } else {
? ? ? ? this.$copyText(url)
? ? ? ? ? .then((res) => {
? ? ? ? ? ? this.$refs.addressInput.select(); // 實現(xiàn)選中效果
? ? ? ? ? ? this.$message.success("復制成功!");
? ? ? ? ? })
? ? ? ? ? .catch((err) => {
? ? ? ? ? ? this.$message.error("該瀏覽器不支持自動復制, 請手動復制");
? ? ? ? ? });
? ? ? }
? ? },
? },
};
</script>
?
<style lang="scss" scoped></style>

優(yōu)化一下,我想要復制一個對象,需要做轉(zhuǎn)義,像這樣

<el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose"><span slot="footer" class="dialog-footer"><span>{{ form.address }}</span><span>{{ form.name }}</span><span>{{ form.password }}</span><el-button @click="dialogVisible = false">取 消</el-button><el-button type="primary" @click="dialogVisible = false">確 定</el-button><el-button type="primary" @click="share(form)">復制</el-button></span></el-dialog>

data(){
return{form: {address: "https://www.baidu.com/", // 地址信息name: "張三",password: "123",},
}
}
 share(url) {if (this.isIE()) {this.$copyText(this.form.password);// this.$refs.addressInput.select(); // 實現(xiàn)選中效果this.$message.success("復制成功!");} else {//此處做轉(zhuǎn)義,并且使用JSON.stringify轉(zhuǎn)一下let obj = {'地址': this.form.address,'用戶名': this.form.name,'密碼': this.form.password}const objectString = JSON.stringify(obj);this.$copyText(objectString).then((res) => {// this.$refs.addressInput.select(); // 實現(xiàn)選中效果this.$message.success("復制成功!");}).catch((err) => {this.$message.error("該瀏覽器不支持自動復制, 請手動復制");})}},

最終結(jié)果為{"地址":"https://www.baidu.com/","用戶名":"張三","密碼":"123"},,win+v剪貼板上也會存在

http://www.risenshineclean.com/news/29152.html

相關(guān)文章:

  • 英語網(wǎng)站建設(shè)如何制作一個公司網(wǎng)站
  • 上海網(wǎng)站建設(shè)平臺站霸網(wǎng)絡(luò)seo學習網(wǎng)站
  • 做網(wǎng)站有一個火箭回頂部網(wǎng)站優(yōu)化關(guān)鍵詞公司
  • 做cpa的博客網(wǎng)站類型博客網(wǎng)
  • 優(yōu)惠券推廣網(wǎng)站怎么做seo怎么搞
  • nas網(wǎng)站怎么做網(wǎng)站時事新聞最新2022
  • 順德樂從有做阿里巴巴的網(wǎng)站嗎sem競價專員是干什么的
  • 做網(wǎng)站視頻圖片加載不出來企業(yè)網(wǎng)站模板下載
  • 情感視頻素材網(wǎng)站劉連康seo培訓哪家強
  • 網(wǎng)站建設(shè)和網(wǎng)站推廣可以同一家做嗎網(wǎng)站優(yōu)化排名金蘋果系統(tǒng)
  • 企業(yè)網(wǎng)站建設(shè)英文超級外鏈
  • 手機網(wǎng)站哪家好西安百度推廣優(yōu)化
  • 網(wǎng)站開發(fā) 英文文章百度收錄快的發(fā)帖平臺
  • 福州網(wǎng)頁鄭州seo排名優(yōu)化公司
  • 汕頭網(wǎng)站建設(shè)制作公司衡陽seo快速排名
  • 分類信息網(wǎng)站成都搭建如何搭建一個網(wǎng)站平臺
  • 做網(wǎng)站的點子站長之家ppt素材
  • 同程網(wǎng)站建設(shè)分析朝陽網(wǎng)站建設(shè)公司
  • 深圳住建委網(wǎng)站智謀網(wǎng)站優(yōu)化公司
  • html5門戶網(wǎng)站模板百度人工客服電話多少
  • 鄭州做網(wǎng)站九零后排名點擊工具
  • 網(wǎng)站開發(fā)程序員 工資百度云怎么找資源
  • 貴陽網(wǎng)站建設(shè)多少錢?影視后期培訓機構(gòu)全國排名
  • 如何搭建公司網(wǎng)站上海公關(guān)公司
  • 做美圖 網(wǎng)站有哪些付費惡意點擊軟件
  • 做局域網(wǎng)網(wǎng)站教程東莞網(wǎng)絡(luò)優(yōu)化調(diào)查公司
  • 慈溪企業(yè)排名網(wǎng)站培訓機構(gòu)排名全國十大教育機構(gòu)排名
  • 做腳本網(wǎng)站建站公司最新報價
  • 網(wǎng)站海外推廣哪家好怎么在百度上發(fā)表文章
  • 怎樣做已有網(wǎng)站的編輯維護四川聚順成網(wǎng)絡(luò)科技有限公司