Riot.mount (*) has no effect

Simple problem here, but unfortunately cannot solve. As the title mentioned, I cannot get Riot to show the content of its custom tag.

<!DOCTYPE html>
<html>
<head></head>
<body>
    <hello></hello>
    <script type="text/javascript" src="node_modules/riot/riot.min.js"></script>
    <script type="text/javascript"> riot.mount('*'); </script>

    <script type="text/javascript" src="bower_components/lodash/lodash.min.js"></script>
    <script type="text/javascript" src="bower_components/jquery/dist/jquery.min.js"></script>
    <script type="text/javascript" src="bower_components/toastr/toastr.min.js"></script>
    <script type="text/javascript" src="js/init.js"></script>
    <script type="text/javascript" src="js/config.js"></script>
    <script type="text/javascript" src="js/util.js"></script>
    <script type="text/javascript" src="js/hello.js"></script>
</body>

      

hello.js is the generated js, here is its code:

riot.tag('hello', '<div> asdasd </div>', function(opts) {
});

      

And here's its HTML:

<hello>
    <div>
        asdasd
    </div>
    <script>
    </script>
</hello>

      

+3


source to share


2 answers


You cannot mount your tag before declaring it.

You need to do in the following order:

Turn on riot:

<script type="text/javascript" src="node_modules/riot/riot.min.js"></script>

      



Declare tags:

<script type="text/javascript" src="js/init.js"></script>
<script type="text/javascript" src="js/config.js"></script>
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript" src="js/hello.js"></script>

      

Install the declared tags:

<script type="text/javascript"> riot.mount('*'); </script>

      

+5


source


Woops. Scrap it. Moved hello.js just below riot.min.js and it worked. Obviously, placing there and above the mount is critical.



0


source







All Articles