Vue Webpack templateとマテリアライズを使用する私の設定です:
ビルド/ index.htmlには
var webpack = require('webpack')
module.exports =
resolve: {
alias: {
...
'jquery': 'materialize-css/node_modules/jquery/dist/jquery.js'
}
},
module: {
rules: [
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
...
options: {
limit: 10000
....
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jquery: 'jquery',
jQuery: 'jquery',
'window.$': 'jquery',
'window.jQuery': 'jquery'
})
]
}
をwebpack.base.conf.js
<head>
...
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
package.json
{
...
"dependencies": {
"materialize-css": "^0.98.2",
...
"devDependencies": {
"@types/jquery": "^2.0.43", // ==> if using typescript
のsrc/main.js
import 'materialize-css'
import 'materialize-css/dist/css/materialize.css'
ので、以下のような "入力選択フィールド" のため:
<div class="input-field" ref="myInput">
<select>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label>Materialize Select</label>
</div>
...あなたのmounted
ライフサイクルフックにこのコードを置くことができます:
mounted() {
$(this.$refs.myInput).material_select()
[material input](http://stackoverflow.com/q/40888352/1610034)と[this fiddle](https://jsfiddle.net/sanjeevks121/t3ntexff/)でこの質問をご覧ください。 – Saurabh