handleShareCoursescourseId const baseUrl = windowlocationhrefreplacethis$routepath ; const shareHref = $baseUrlshareCourses$courseId; let htmlStr = div style=width 350px;overflow
<script>
import { ref } from 'vue';
export default {
setup() {
const handleShareCourses = (courseId) => {
const baseUrl = window.location.href.replace(this.$route.path, '');
const shareHref = `${baseUrl}/shareCourses/${courseId}`;
let htmlStr = `<div style="width: 350px;overflow-y: scroll;">${shareHref}</div>`;
const confirmButtonText = '复制链接';
const center = true;
const dangerouslyUseHTMLString = true;
const callback = (action) => {
if (action === 'cancel') {
return;
}
const rng = document.createElement('input');
rng.setAttribute('value', shareHref);
document.body.appendChild(rng);
rng.select();
document.execCommand('Copy');
document.body.removeChild(rng);
this.$message({
type: 'info',
message: '链接已经复制在粘贴版'
});
};
window.alert(htmlStr, '分享课程', { confirmButtonText, center, dangerouslyUseHTMLString, callback });
};
return {
handleShareCourses
};
}
};
</script
原文地址: https://www.cveoy.top/t/topic/ckR4 著作权归作者所有。请勿转载和采集!