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
Docker Compose is a Docker tool for defining and ...
Installation sequence rpm -ivh mysql-community-co...
Provide login and obtain user information data in...
Common scenarios for Nginx forwarding socket port...
1. Two words at the beginning Hello everyone, my ...
Implementation ideas: First of all, the alarm inf...
Table of contents 1. Check whether MySQL has been...
I have several tomcats here. If I use them at the...
.y { background: url(//img.jbzj.com/images/o_y.pn...
If you want the application service in the Docker...
1. Introduction A few days ago, I encountered a p...
I recently used nginx in a project, and used Java...
When a website is maliciously requested, blacklis...
1. px px is the abbreviation of pixel, a relative...
Table of contents Preface background Big guess Fi...