Project ScenarioAdd a custom watermark to the entire background of the project. You can change the watermark text, font color, etc. Implementation ideas
Achieve results Implementation Code <template> <div class="water-marker" > <div v-waterMarker="{text:'Carlo vest - All rights reserved',textColor:'rgba(180, 180, 180, 0.4)'}"> <div class="water-marker-item">Testing problem, testing problem, testing problem, testing problem, testing problem, testing problem</div> </div> </div> </template> <script> import waterMarker from '../../directive/test/waterMarker' export default { directives: { waterMarker }, data(){ return { } }, methods:{ } } </script> <style lang="scss"> .water-marker{ height: 300px; .water-marker-item{ line-height: 300px; } } </style> The waterMarker.js file is as follows: function addWaterMarker(str, parentNode, font, textColor) { // Watermark text, parent element, font, text color var can = document.createElement('canvas') parentNode.appendChild(can) can.width = 200 can.height = 150 can.style.display = 'none' var cans = can.getContext('2d') cans.rotate((-20 * Math.PI) / 180) cans.font = font || '16px Microsoft JhengHei' cans.fillStyle = textColor || 'rgba(180, 180, 180, 0.3)' cans.textAlign = 'left' cans.textBaseline = 'Middle' cans.fillText(str, can.width / 10, can.height / 2) parentNode.style.backgroundImage = 'url(' + can.toDataURL('image/png') + ')' } const waterMarker = { bind: function (el, binding) { addWaterMarker(binding.value.text, el, binding.value.font, binding.value.textColor) }, } export default waterMarker This is the end of this article about how to use custom instructions in Vue to add a watermark at the bottom of the page. For more relevant content about adding a watermark at the bottom of the Vue page, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Example of using CASE WHEN in MySQL sorting
>>: VSCode+CMake+Clang+GCC environment construction tutorial under win10
Flex Layout Flex is the abbreviation of Flexible ...
When we add an svg image to display, react prompt...
Table of contents 1. Introduction 2. Main text 2....
Table of contents React Fiber Creation 1. Before ...
1. MySQL self-connection MySQL sometimes needs to...
INSERT INTO hk_test(username, passwd) VALUES (...
This article introduces 4 methods to achieve mask...
Table of contents What is cgroup Composition of c...
Brief review: Browser compatibility issues are of...
This article shares the specific code of vue3 enc...
Adding a network interface to the container 1 Run...
The key features of the InnoDB storage engine inc...
Open the folder C:\web\mysql-8.0.11 that you just...
1. Installation apt-get install mysql-server requ...
500 (Internal Server Error) The server encountere...