-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
2,156 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,43 @@ | ||
const eslintConfig = { | ||
"root": true, | ||
"parserOptions": { | ||
"parser": "babel-eslint", | ||
"ecmaVersion": 7, | ||
"sourceType": "module", | ||
"ecmaFeatures": { | ||
"jsx": true | ||
root: true, | ||
parserOptions: { | ||
parser: '@babel/eslint-parser', | ||
ecmaVersion: 7, | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
jsx: true | ||
} | ||
}, | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true | ||
env: { | ||
browser: true, | ||
es6: true, | ||
node: true | ||
}, | ||
"globals":{ | ||
"console": true | ||
globals: { | ||
console: true | ||
}, | ||
"extends": [ | ||
"plugin:vue/essential", | ||
"standard" | ||
extends: [ | ||
'plugin:vue/essential', | ||
'plugin:vue/recommended', | ||
'@vue/standard' | ||
], | ||
"plugins": [ | ||
"vue" | ||
plugins: [ | ||
'@babel', | ||
'vue' | ||
], | ||
"rules": { | ||
"no-var": 1, | ||
"no-alert": 1, | ||
"no-ternary": 0, | ||
"no-self-assign": 0, | ||
"standard/no-callback-literal": 0, | ||
"func-call-spacing": 0, | ||
"prefer-promise-reject-errors": 0, | ||
"no-unused-vars": 1, | ||
"no-debugger": 1, | ||
"no-console": 1, | ||
'no-useless-constructor': "off" | ||
rules: { | ||
'no-var': 1, | ||
'no-alert': 1, | ||
'no-ternary': 0, | ||
'no-self-assign': 0, | ||
'standard/no-callback-literal': 0, | ||
'func-call-spacing': 0, | ||
'prefer-promise-reject-errors': 0, | ||
'no-unused-vars': 1, | ||
'no-debugger': 1, | ||
'no-console': 1, | ||
'no-useless-constructor': 'off' | ||
} | ||
}; | ||
} | ||
|
||
module.exports = eslintConfig; | ||
module.exports = eslintConfig |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin') | ||
|
||
const VueLoaderPlugin = require('vue-loader/lib/plugin'); | ||
|
||
function resolve (dir) { | ||
return path.join(process.cwd(), dir) | ||
} | ||
|
||
const webpackConfig = { | ||
mode: process.env.NODE_ENV, | ||
entry: './example/main.js', | ||
output: { | ||
path: resolve('./example/dist'), | ||
filename: '[name].[hash:7].js', | ||
}, | ||
resolve: { | ||
alias: { | ||
vue$: 'vue/dist/vue.esm.js', | ||
'source': resolve('./src'), | ||
'@': resolve('./example/src') | ||
}, | ||
extensions: ['*', '.js', '.vue', '.json'] | ||
}, | ||
devServer: { | ||
publicPath: '/', | ||
port: 8085, | ||
quiet: true, | ||
hot: true, | ||
open: true, | ||
openPage: 'affix-example' | ||
}, | ||
performance: { | ||
hints: false | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
enforce: 'pre', | ||
test: /\.(vue|jsx?)$/, | ||
exclude: /node_modules/, | ||
loader: 'eslint-loader' | ||
}, | ||
{ | ||
test: /\.(jsx?|babel|es6)$/, | ||
include: process.cwd(), | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
extends: resolve('babel.config.js') | ||
} | ||
} | ||
}, | ||
{ | ||
test: /\.vue$/, | ||
loader: 'vue-loader', | ||
options: { | ||
compilerOptions: { | ||
preserveWhitespace: false | ||
} | ||
} | ||
}, | ||
{ | ||
test: /\.(scss|css)$/, | ||
use: [ | ||
'vue-style-loader', | ||
'css-loader', | ||
'sass-loader' | ||
] | ||
}, | ||
{ | ||
test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/, | ||
loader: 'url-loader', | ||
query: { | ||
limit: 10000, | ||
name: '[name].[hash:7].[ext]' | ||
} | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
new webpack.HotModuleReplacementPlugin(), | ||
new HtmlWebpackPlugin({ | ||
template: './example/index.html', | ||
}), | ||
new VueLoaderPlugin(), | ||
new webpack.LoaderOptionsPlugin({ | ||
vue: { | ||
compilerOptions: { | ||
preserveWhitespace: false | ||
} | ||
} | ||
}), | ||
new FriendlyErrorsWebpackPlugin({ | ||
clearConsole: false, | ||
onErrors: (severity, errors) => { | ||
if (severity !== 'error') { | ||
return | ||
} | ||
const error = errors[0] | ||
notifier.notify({ | ||
title: 'Webpack error', | ||
message: `${severity}: ${error.name}`, | ||
subtitle: error.file || '' | ||
}) | ||
} | ||
}) | ||
], | ||
optimization: { | ||
minimizer: [] | ||
}, | ||
devtool: '#eval-source-map' | ||
}; | ||
|
||
module.exports = webpackConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<template> | ||
<div> | ||
<router-view /> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
name: 'App' | ||
} | ||
</script> | ||
<style lang="scss"> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title></title> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="renderer" content="webkit" /> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="Content-Language" content="zh-CN" /> | ||
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Vue from 'vue' | ||
import router from './router.js' | ||
|
||
import HocElementAffix from 'source/main.js' | ||
import App from './App.vue' | ||
|
||
Vue.use(HocElementAffix) | ||
|
||
new Vue({ | ||
router, | ||
render: h => h(App) | ||
}).$mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Vue from 'vue' | ||
import VueRouter from 'vue-router' | ||
|
||
const Layout = () => import('@/components/Layout') | ||
const importModule = (filePath) => { | ||
return () => import(`@/${filePath}`) | ||
} | ||
|
||
const routes = [{ | ||
path: '/', | ||
component: Layout, | ||
children: [ | ||
{ | ||
path: 'affix-example', | ||
component: importModule('views/ExampleAffix') | ||
} | ||
] | ||
}] | ||
|
||
Vue.use(VueRouter) | ||
export default new VueRouter({ | ||
routes, | ||
mode: 'history' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<template> | ||
<div> | ||
<router-view /> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
name: 'Layout' | ||
} | ||
</script> | ||
|
||
<style> | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
body { | ||
-moz-osx-font-smoothing: grayscale; | ||
-webkit-font-smoothing: antialiased; | ||
text-rendering: optimizeLegibility; | ||
font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; | ||
} | ||
html { | ||
box-sizing: border-box; | ||
font-size: 14px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<template> | ||
<div class="box-container"> | ||
<div class="content"> | ||
<div class="long-list"> | ||
<div | ||
v-for="(item, index) in 50" | ||
:key="index" | ||
class="long" | ||
> | ||
<template | ||
v-if="index === 2" | ||
> | ||
<hoc-el-affix> | ||
<div class="box"> | ||
吸顶 | ||
</div> | ||
</hoc-el-affix> | ||
</template> | ||
<template | ||
v-else-if="index === 7" | ||
> | ||
<hoc-el-affix | ||
:offset-top="120" | ||
> | ||
<div class="box"> | ||
距离顶部120px时固定 | ||
</div> | ||
</hoc-el-affix> | ||
</template> | ||
<template | ||
v-else | ||
> | ||
{{ index === 99 ? '到底了' : `占位符${index + 1}` }} | ||
</template> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'ExampleAffix' | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.box-container { | ||
.content { | ||
position: relative; | ||
width: 300px; | ||
margin: 0 auto; | ||
text-align: center; | ||
.box { | ||
width: 300px; | ||
height: 50px; | ||
line-height: 50px; | ||
border: 1px solid #000; | ||
} | ||
.long-list { | ||
.long { | ||
height: 50px; | ||
line-height: 50px; | ||
font-size: 16px; | ||
} | ||
} | ||
} | ||
} | ||
</style> |
Oops, something went wrong.