javascript - 将 html 文件转换为 vue.js

标签 javascript html vue.js

我有 login.vue 文件,我想添加样式,我想包含 jscss 文件。我不知道如何在 login.vue 文件中做。

下面是html文件

<!DOCTYPE html>
<html lang="en-US">
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1 user-scalable=no">
    <title>Teledirect Group &rsaquo; Log In</title>
    <link href="css/icons.css" rel="stylesheet">
    <link rel="icon" href="img/ico/tlogofvicon.png" type="image/png">
    <link rel="stylesheet" href="css/app.css">
    <link rel="stylesheet" id="dashicons-css" href="css/dashicons.min.css" type="text/css" media="all">
    <link rel='stylesheet' id='login-css'  href='css/login.min.css' type='text/css' media='all' /> 
    <style>
    .body_css{ 
        background: #fefefe none repeat scroll 0 0;
        color: #0a0a0a;
        font-family: "Helvetica Neue",Helvetica,Roboto,Arial,sans-serif;
        font-weight: normal;
        line-height: 1.5;
        margin: 0;
        padding: 0;
    }
    </style>
    </head> 
    <body class="body_css">
       <div class="main">
          <div id="particles-js" style="position: relative">
              <img src="img/logo-white.svg" alt="" class="logo" style="top: -51px;">
             <div style="text-align: center;
                          color: #fff;
                          position: absolute;
                          top: 44%;
                          margin-top: 50px;
                          width: 100%;
                          font-size: 16px;
                          font-weight: bold; ">
             Expense Claim System
             </div>
          </div>

             <div class="row login-cont">
              <div class="content form op2">
              <input type="hidden" name="reset_email" id="reset_email" value="<?php echo $remail;?>" />
              <input type="hidden" name="ccode" id="ccode" value="<?php echo $ccode;?>" /> 
              <div id="loginfrm">
                    <form name="login-form" id="login-form" method="post"> 
                          <span class="error-msg" style="display:none">Please enter your email | Please enter your password</span>
                        <p class="userlogin1">
                            <label for="user_login">
                            <input type="text" name="uname" id="uname" class="input" value="<?php if(isset($_COOKIE["member_login"])) { echo $_COOKIE["member_login"]; } ?>" size="20" placeholder="Username" /></label>
                        </p>
                        <p class="passwrd1">
                            <label for="user_pass" >
                            <input type="password" name="pwd" id="pwd" class="input" value="" size="20" placeholder="Password" /></label> 
                        </p>
                        <p class="forgetmenot1"> 
                        <label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" value="forever"  /> Remember Me</label></p>
                        <p class="submit1">
                            <input type="hidden" id="action" name="action" value="login" >
                            <input type="submit" name="wp-submit" id="real_submit"  class="btn" value="Login" />
                                <input type="hidden" name="redirect_to" value="" />
                                <input type="hidden" name="testcookie" value="1" />
                                <span id="response_submit" style="display:none">
                                <a href="" class="btn btn-default pull-right">Checking... <img width="25" src="img/loading.gif" /></a>
                                </span>
                        </p>
                      <p>
                        <a href="#" title="Password Lost and Found"  class="frgt-password" style="cursor:pointer">Forgot password?</a>
                      </p>
                    </form>
                    </div> 
                    <div class="panel-footer gray-lighter-bg bt" id="response_note" style="display:none;">
                    </div>
                     <div id="forgetfrm" style="display:none"> 
                     <!-- forget password -->
                     <form name="lostpasswordform" id="lostpasswordform" method="post">
                        <span class="error-msg" style="display:none">Please enter your email or username</span>
                        <p>
                            <label for="user_login">
                                <input type="text" name="user_login" id="user_login"  class="input" value="" size="20" placeholder="Email or Username"/>
                            </label> 
                        </p> 
                        <input type="hidden" name="redirect_to" value="" />
                        <p class="submit" style="width:1000px;text-align:center;">  
                            <input type="submit" name="fp_submit" id="fp_submit"  value="Get New Password" />  
                        </p> 
                     </form>   
                     <p id="nav"><a href="" class="login-rvt">Log in</a></p>
                     <!-- End of forget password --> 
                </div>

                <div id="resetpwd" style="display:none"> 
                <form name="fresetpassform" id="fresetpassform" action="#" method="post" autocomplete="off"> 

                <span class="error-msg" style="display:none" >Please enter your new password</span>

                <p>
                    <label for="pass1" id="confm_pass1">
                    <input type="password" name="fpass1" id="fpass1" class="input" size="20" value="" autocomplete="off" placeholder="New Password" /></label>
                </p>
                <p>
                    <label for="pass2" id="confm_pass">
                    <input type="password" name="fpass2" id="fpass2"  class="input" size="20" value="" autocomplete="off" placeholder="Confirm new password" /></label>
                </p>
                <p class="submit" style="width:1000px;text-align:center;">
                <input type="submit" name="fwp-submit" id="fwp-submit" value="Reset Password" /></p> 
                </form> 
          </div> 
          <div class="clear"></div>
          <footer>
                <p class="account-copyright"><span>Copyright © <?php echo date("Y"); ?> </span><span>Teledirectgroup</span>. <span>All rights reserved.</span></p>
          </footer>
        </div>

        <!-- Important javascript libs(put in all pages) -->
        <script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
        <script>
            window.jQuery || document.write('<script src="{site_url}js/libs/jquery-2.1.1.min.js">\x3C/script>')
        </script>
        <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
        <script>
            window.jQuery || document.write('<script src="js/libs/jquery-ui-1.10.4.min.js">\x3C/script>')
        </script>
        <!-- Bootstrap plugins -->
        <script src="js/bootstrap/bootstrap.js"></script>
        <!-- Form plugins -->
        <script src="plugins/jquery.validate.js"></script>

        <!-- Top particles background -->
        <script src="js/pages/particles.js"></script>
        <script src="js/pages/app.js"></script>
        <script src="js/pages/login.js"></script>

        </body>
</html>



and below is login.vue file:

<template>

    <div class="card_data align-items-center">

        <b-card style="max-width: 25rem;" class="mb-2 shadow p-3 mb-5 bg-white rounded">
            <b-alert variant="danger" dismissible v-model="showDismissibleAlert">
                {{ alertMessage }}
            </b-alert>
            <h4 style="text-align: center">Login Panel</h4>
            <hr>
            <b-form @submit="onSubmit">
                <b-form-group id="username" label="Username:" label-for="username" class="font-weight-bold">
                    <b-form-input id="username" type="text" v-model="form.username" required placeholder="Enter email or merchant id" />
                </b-form-group>

                <b-form-group id="password" label="Password:" label-for="password" class="font-weight-bold">
                    <b-form-input id="password" type="password" v-model="form.password" required placeholder="Enter password" />
                </b-form-group>
                <b-row class="mt-4">
                    <b-col class="text-center">
                        <b-button type="submit" variant="primary" size="lg" class="text-center">Submit</b-button>
                    </b-col>
                </b-row>
            </b-form>
        </b-card>

    </div>

</template>

<style>
    .card_data {

        background: #fefefe none repeat scroll 0 0;
        color: #0a0a0a;
        font-family: "Helvetica Neue",Helvetica,Roboto,Arial,sans-serif;
        font-weight: normal;
        line-height: 1.5;
        margin: 0;
        padding: 0;

    }


</style>

<script>
    export default {
        name: 'LoginPage',
        data() {
            return {
                form: {
                    username: '',
                    password: ''
                },
                show: true,
                alertMessage: 'Wrong Credentials',
                showDismissibleAlert: false,
                baseUrl: '',
            }
        },
        methods: {
            onSubmit(evt) {
                let loader = this.$loading.show({
                    container: this.fullPage ? null : this.$refs.file,
                });

                this.showDismissibleAlert = false
                evt.preventDefault();

                var bodyFormData = new FormData();
                bodyFormData.set('email', this.form.username);
                bodyFormData.set('password', this.form.password);
                this.axios({
                        method: 'post',
                        url: this.baseUrl + 'portal/login',
                        data: bodyFormData
                    })
                    .then((response) => {
                        loader.hide();
                        if (response.data.success == true) {
                            this.showDismissibleAlert = false;
                            this.$store.commit('setLogin', true );
                            this.$toast.open({
                                message: 'Login was success',
                                type: 'success'
                            });
                            // console.log(this.$store.getters.getLogin);
                            this.$router.push('/');

                        } else {
                                this.$toast.open({
                                message: 'Invalid Credentials',
                                type: 'error'
                            });
                        }
                    })
                    .catch(function(response) {
                        loader.hide();
                    });
            },

            onReset(evt) {
                evt.preventDefault()
                this.form.username = '';
                this.form.password = '';
                this.show = false;
                this.$nextTick(() => {
                    this.show = true;
                })
            }
        },
        mounted() {
            this.baseUrl = this.$store.getters.getUrl;
        },
    }

</script>

我有一个 login.vue 文件,我想添加样式,我想包含 jscss 文件。 我不知道如何在 login.vue 文件中执行操作。

最佳答案

你可以像这样在你的样式标签中导入它:

 <style>
    @import './css/app.css';
 </style>

至于 js 文件,只需将其导入导出默认值的顶部,如下所示:

import myJsFile from "./js/myJsFile"

export default {
...
}

关于javascript - 将 html 文件转换为 vue.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57474313/

相关文章:

javascript - 事件绑定(bind)如何处理传入的值

javascript - 相对于链接定位一个弹出式 div

javascript - 如何正确使用JavaScriptStringEncode()方法?

javascript - 如何不断检查 div 的类

javascript - 为什么 RxJS Observable 不能在 Vue.js 应用程序 div 中工作?

javascript - imacros,我正在尝试从网页中提取图像文件的名称

javascript - 使用 Google reCAPTCHA 验证表单提交

javascript - 拖动时摆脱半透明圆形CSS div中的背景颜色

vue.js - 结果缺少 allposts 属性

vue.js - vue props : Should I pass the object or its properties? 区别大不大?