Struggling to develop a Vue.js SPA chat application, encountering issues with Materialize CSS and JS. The JS doesn't function properly on initial load and requires a page reload to work. No errors are appearing in the console, making it challenging to pinpoint the problem.
Below is the content of index.html:
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">
<title>Chat</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js"></script>
</body>
</html>
Below is the component where the issue lies:
<template>
<div class="container reg">
<h1 class="text-centered">Registration</h1>
<form @submit.prevent="register">
* Additional form fields *
<div class="input-field col s12">
<select>
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label>Materialize Select</label>
</div>
<input type="submit" value="Register" />
</form>
<router-link :to="{ name: 'login' }">
<button>Login</button>
</router-link>
</div>
</template>
<script>
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('select');
var instances = M.FormSelect.init(elems, null);
});
export default {
data: function () {
return {
};
},
methods: {
Register () {
}
}
}
</script>