jquery 如何在静态网站中使用Faceapp.js?

ibps3vxo  于 2023-06-22  发布在  jQuery
关注(0)|答案(2)|浏览(89)

安装node_modules并添加faceapp.js作为依赖项。尝试使用faceapp.js,但没有成功。

<!DOCTYPE html>
    <html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <link rel="stylesheet" href="assets/css/style.css" />
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <script src="node_modules/jquery/dist/jquery.min.js"></script>
        <script src="node_modules/faceapp/bin/faceapp.js"></script>
        <script src="assets/js/script.js"></script>

    </head>

    <body>
        <h1 class="text-center">Faceapp</h1>

    </body>

    </html>

JavaScript

const faceapp = require('faceapp');

let image = await faceapp.process('assets/images/ajith.jpg', 'smile_2');
rbl8hiat

rbl8hiat1#

看起来你想在静态web中添加一个npm模块。你首先需要捆绑脚本和所需的模块,并将捆绑的脚本包含到静态html中。我建议查看browserifywebpack来了解如何做到这一点。

swvgeqrz

swvgeqrz2#

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="assets/css/style.css" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <script src="node_modules/jquery/dist/jquery.min.js"></script>
    <script src="node_modules/faceapp/bin/faceapp.js"></script>
    <script src="assets/js/script.js"></script>

</head>

<body>
    <h1 class="text-center">Faceapp</h1>

</body>

</html>[`enter image description here`][1]

相关问题