How to let a function execute without binding an event by vue

the following vue components:

<template>
    <div class="parent">
       <canvas ref="canvas2" ></canvas>
    </div>
</template>
<script type="text/ecmascript-6">
    export default {
        methods: {
            writeFont(){
                var canvas = this.$refs.canvas2;
                var ctx = canvas.getContext("2d");
                 ctx.font = "24px Arial";
                ctx.fillStyle = "-sharp333333";
                ctx.fillText("", 20, 20);
            }
        }
    }
</script>

how to have the writeFont method execute when the component loads instead of binding it to a tag.

Feb.28,2021

can be executed in created in the component lifecycle of vue

    export default {
        created(){
            this.writeFont()
        }
        methods: {
            writeFont(){
                var canvas = this.$refs.canvas2;
                var ctx = canvas.getContext('2d');
                 ctx.font = '24px Arial';
                ctx.fillStyle = '-sharp333333';
                ctx.fillText('', 20, 20);
            }
        }
    }

see the official document ide/instance.html-sharp%E5%AE%9E%E4%BE%8B%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E9%92%A9%E5%AD%90" rel=" nofollow noreferrer "> https://cn.vuejs.org/v2/guide.

for details.

execute

in the created or mounted hook
  

learn about the life cycle of vue. To sum up, everything said upstairs is true, except for the landlord ~

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a9c3-2c256.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a9c3-2c256.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?