作者 lihongjuan

1

正在显示 81 个修改的文件 包含 2205 行增加0 行删除
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"],
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"]
}
}
}
... ...
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
... ...
.DS_Store
node_modules/
/dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/test/unit/coverage/
/test/e2e/reports/
selenium-debug.log
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
... ...
// https://github.com/michael-ciniawsky/postcss-load-config
module.exports = {
"plugins": {
"postcss-import": {},
"postcss-url": {},
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer": {}
}
}
... ...
# tangyuan
> A Vue.js project
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
# run unit tests
npm run unit
# run e2e tests
npm run e2e
# run all tests
npm test
```
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
... ...
'use strict'
require('./check-versions')()
process.env.NODE_ENV = 'production'
const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')
const spinner = ora('building for production...')
spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, (err, stats) => {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
chunks: false,
chunkModules: false
}) + '\n\n')
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}
console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})
... ...
'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}
const versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
}
]
if (shell.which('npm')) {
versionRequirements.push({
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
})
}
module.exports = function () {
const warnings = []
for (let i = 0; i < versionRequirements.length; i++) {
const mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}
if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}
... ...
'use strict'
const path = require('path')
const config = require('../config')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const packageConfig = require('../package.json')
exports.assetsPath = function (_path) {
const assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}
exports.cssLoaders = function (options) {
options = options || {}
const cssLoader = {
loader: 'css-loader',
options: {
sourceMap: options.sourceMap
}
}
const postcssLoader = {
loader: 'postcss-loader',
options: {
sourceMap: options.sourceMap
}
}
// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
const output = []
const loaders = exports.cssLoaders(options)
for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}
exports.createNotifierCallback = () => {
const notifier = require('node-notifier')
return (severity, errors) => {
if (severity !== 'error') return
const error = errors[0]
const filename = error.file && error.file.split('!').pop()
notifier.notify({
title: packageConfig.name,
message: severity + ': ' + error.name,
subtitle: filename || '',
icon: path.join(__dirname, 'logo.png')
})
}
}
... ...
'use strict'
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'
const sourceMapEnabled = isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap
module.exports = {
loaders: utils.cssLoaders({
sourceMap: sourceMapEnabled,
extract: isProduction
}),
cssSourceMap: sourceMapEnabled,
cacheBusting: config.dev.cacheBusting,
transformToRequire: {
video: ['src', 'poster'],
source: 'src',
img: 'src',
image: 'xlink:href'
}
}
... ...
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
function resolve (dir) {
return path.join(__dirname, '..', dir)
}
module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
}
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
}
... ...
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const path = require('path')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')
const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)
const devWebpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
},
// cheap-module-eval-source-map is faster for development
devtool: config.dev.devtool,
// these devServer options should be customized in /config/index.js
devServer: {
clientLogLevel: 'warning',
historyApiFallback: {
rewrites: [
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
],
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll,
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/dev.env')
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
}))
resolve(devWebpackConfig)
}
})
})
... ...
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const env = process.env.NODE_ENV === 'testing'
? require('../config/test.env')
: require('../config/prod.env')
const webpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true,
usePostCSS: true
})
},
devtool: config.build.productionSourceMap ? config.build.devtool : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false
}
},
sourceMap: config.build.productionSourceMap,
parallel: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css'),
// Setting the following option to `false` will not extract CSS from codesplit chunks.
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
allChunks: true,
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: config.build.productionSourceMap
? { safe: true, map: { inline: false } }
: { safe: true }
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: process.env.NODE_ENV === 'testing'
? 'index.html'
: config.build.index,
template: 'index.html',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// keep module.id stable when vendor modules does not change
new webpack.HashedModuleIdsPlugin(),
// enable scope hoisting
new webpack.optimize.ModuleConcatenationPlugin(),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks (module) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
// This instance extracts shared chunks from code splitted chunks and bundles them
// in a separate chunk, similar to the vendor chunk
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
async: 'vendor-async',
children: true,
minChunks: 3
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
if (config.build.productionGzip) {
const CompressionWebpackPlugin = require('compression-webpack-plugin')
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' +
config.build.productionGzipExtensions.join('|') +
')$'
),
threshold: 10240,
minRatio: 0.8
})
)
}
if (config.build.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = webpackConfig
... ...
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"'
})
... ...
'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
// Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-module-eval-source-map',
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: true,
cssSourceMap: true
},
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
/**
* Source Maps
*/
productionSourceMap: true,
// https://webpack.js.org/configuration/devtool/#production
devtool: '#source-map',
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
}
}
... ...
'use strict'
module.exports = {
NODE_ENV: '"production"'
}
... ...
'use strict'
const merge = require('webpack-merge')
const devEnv = require('./dev.env')
module.exports = merge(devEnv, {
NODE_ENV: '"testing"'
})
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>tangyuan</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
<script>
// 尺寸计算
function setFontSize() {
document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
};
window.addEventListener('resize', function() {
setFontSize();
}, false);
setFontSize();
</script>
</html>
\ No newline at end of file
... ...
此 diff 太大无法显示。
{
"name": "tangyuan",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "lihongjuan <18848113498@163.com>",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"unit": "jest --config test/unit/jest.conf.js --coverage",
"e2e": "node test/e2e/runner.js",
"test": "npm run unit && npm run e2e",
"build": "node build/build.js"
},
"dependencies": {
"vant": "^2.9.2",
"vue": "^2.5.2",
"vue-router": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-jest": "^21.0.2",
"babel-loader": "^7.1.1",
"babel-plugin-dynamic-import-node": "^1.2.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chalk": "^2.0.1",
"chromedriver": "^2.27.2",
"copy-webpack-plugin": "^4.0.1",
"cross-spawn": "^5.0.1",
"css-loader": "^0.28.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"jest": "^22.0.4",
"jest-serializer-vue": "^0.3.0",
"nightwatch": "^0.9.12",
"node-notifier": "^5.1.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"selenium-server": "^3.0.1",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8",
"vue-jest": "^1.0.2",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
... ...
<template>
<div id="app">
<router-view />
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
<style>
#app {
width: 100%;
}
body,
html {
padding: 0;
margin: 0;
background: #f9f9f9;
}
img {
width: 100%;
height: 100%;
}
.yourow {
width: 0.21rem;
height: 0.21rem;
font-size: 0;
}
/* 搜索框
*/
.searchhead {
width: 100%;
padding: 0.2rem 0.32rem;
box-sizing: border-box;
background: #fff;
}
.searchimg {
width: 0.3rem;
height: 0.28rem;
font-size: 0;
margin-right: 0.11rem;
}
.searchbox {
width: 6.96rem;
height: 0.68rem;
background: #f7f8fa;
border-radius: 0.04rem;
margin: 0 auto;
padding: 0.16rem;
box-sizing: border-box;
}
::-webkit-input-placeholder {
color: #b5bfba;
}
.searchtext {
height: 0.68rem;
color: #b5bfba;
font-size: 0.28rem;
}
.flex {
display: flex;
}
.flexone {
display: flex;
align-items: center;
}
.flextwo {
display: flex;
align-items: center;
justify-content: space-between;
}
.flexthree {
display: flex;
align-items: center;
justify-content: center;
}
.flexfour {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.flexfive {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
}
.flexsix {
display: flex;
align-items: center;
justify-content: space-around;
}
.flexseven {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.register {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 5;
}
input {
width: 100%;
background: transparent;
border: none;
outline: none;
}
</style>
... ...
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<h2>Essential Links</h2>
<ul>
<li>
<a
href="https://vuejs.org"
target="_blank"
>
Core Docs
</a>
</li>
<li>
<a
href="https://forum.vuejs.org"
target="_blank"
>
Forum
</a>
</li>
<li>
<a
href="https://chat.vuejs.org"
target="_blank"
>
Community Chat
</a>
</li>
<li>
<a
href="https://twitter.com/vuejs"
target="_blank"
>
Twitter
</a>
</li>
<br>
<li>
<a
href="http://vuejs-templates.github.io/webpack/"
target="_blank"
>
Docs for This Template
</a>
</li>
</ul>
<h2>Ecosystem</h2>
<ul>
<li>
<a
href="http://router.vuejs.org/"
target="_blank"
>
vue-router
</a>
</li>
<li>
<a
href="http://vuex.vuejs.org/"
target="_blank"
>
vuex
</a>
</li>
<li>
<a
href="http://vue-loader.vuejs.org/"
target="_blank"
>
vue-loader
</a>
</li>
<li>
<a
href="https://github.com/vuejs/awesome-vue"
target="_blank"
>
awesome-vue
</a>
</li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
... ...
<template>
<div class="container">
活东中心
<tabBar v-bind:active="2" />
</div>
</template>
<script>
import tabBar from "@/components/views/tabBar.vue";
export default {
components: {
tabBar
},
data() {
return {
selnav: 2
};
},
methods: {
selcourse(e) {
console.log(37344);
console.log(e);
this.selnav = e.currentTarget.dataset.id;
}
}
};
</script>
<style></style>
... ...
<template>
<div class="container">
<!-- 顶部搜素 -->
<div class="searchhead">
<div class="searchbox flexone">
<div class="searchimg">
<img src="../../../assets/search.png" alt />
</div>
<input
type="text"
placeholder="搜索你感兴趣的课程文章"
class="searchtext"
/>
</div>
</div>
<!-- 课程列表 -->
<div class="courseitem flex">
<div class="courseimg">
<img src="../../../assets/courseimg.png" alt />
</div>
<div class="courseright">
<div class="coursetitle">关于减肥,除了科学运动</div>
<div class="zhibo flexone">
<img src="../../../assets/zhibo.png" alt class="zhiimg" />
<div class="zhiname">正在直播</div>
</div>
<div class="know flexone">
<span class="morepeople">很多人不能正确理解减肥</span>
<div class="knowmore">
了解详情
<img src="../../../assets/yourow.png" alt class="yourow" />
</div>
</div>
</div>
</div>
<div class="courseitem flex">
<div class="courseimg">
<img src="../../../assets/courseimg.png" alt />
</div>
<div class="courseright">
<div class="coursetitle">关于减肥,除了科学运动</div>
<div class="zhibo flexone">
<img src="../../../assets/ready.png" alt class="zhiimg" />
<div class="zhiname">正在直播</div>
</div>
<div class="know flexone">
<span class="morepeople">很多人不能正确理解减肥</span>
<div class="knowmore">
了解详情
<img src="../../../assets/yourow.png" alt class="yourow" />
</div>
</div>
</div>
</div>
<!-- 课程头部 -->
<div class="coursenav flexone">
<div
class="coursenavleft"
:class="selnav == 0 ? 'selactive' : ''"
:data-id="0"
@click="selectnav"
>
音频课程
</div>
<div
class="coursenavleft"
:class="selnav == 1 ? 'selactive' : ''"
:data-id="1"
@click="selectnav"
>
营养小知识
</div>
</div>
<!-- 课程 -->
<div class="coursebox" v-if="selnav == 0">
<div class="courseboxitem">
<div class="coursenameimg">
<img src="../../../assets/course.png" alt />
</div>
<div class="coursetext">
<div class="coursename">一个月减重20斤,健康减重没有副作用</div>
<div class="courseteacher">讲师:孙俪</div>
</div>
</div>
<div class="courseboxitem">
<div class="coursenameimg">
<img src="../../../assets/course.png" alt />
</div>
<div class="coursetext">
<div class="coursename">一个月减重20斤,健康减重没有副作用</div>
<div class="courseteacher">讲师:孙俪</div>
</div>
</div>
<div class="courseboxitem">
<div class="coursenameimg">
<img src="../../../assets/course.png" alt />
</div>
<div class="coursetext">
<div class="coursename">一个月减重20斤,健康减重没有副作用</div>
<div class="courseteacher">讲师:孙俪</div>
</div>
</div>
<div class="courseboxitem">
<div class="coursenameimg">
<img src="../../../assets/course.png" alt />
</div>
<div class="coursetext">
<div class="coursename">一个月减重20斤,健康减重没有副作用</div>
<div class="courseteacher">讲师:孙俪</div>
</div>
</div>
</div>
<!-- 营养小知识 -->
<div class="coursebox" v-if="selnav == 1">
<div class="courseboxitem">
<div class="coursenameimg">
<img src="../../../assets/knowlage.png" alt />
</div>
<div class="coursetext">
<div class="coursename knowlagename">
一个月减重20斤,健康减重没有副作用
</div>
</div>
</div>
<div class="courseboxitem">
<div class="coursenameimg">
<img src="../../../assets/knowlage.png" alt />
</div>
<div class="coursetext">
<div class="coursename knowlagename">
一个月减重20斤,健康减重没有副作用
</div>
</div>
</div>
<div class="courseboxitem">
<div class="coursenameimg">
<img src="../../../assets/knowlage.png" alt />
</div>
<div class="coursetext">
<div class="coursename knowlagename">
一个月减重20斤,健康减重没有副作用
</div>
</div>
</div>
</div>
<!-- 底部导航 -->
<tabBar v-bind:active="0" />
</div>
</template>
<script>
import tabBar from "@/components/views/tabBar.vue";
export default {
components: {
tabBar
},
data() {
return {
selnav: 0
};
},
methods: {
selectnav(e) {
this.selnav = e.currentTarget.dataset.id;
}
}
};
</script>
<style scoped>
@import "../../../style/course.css";
</style>
... ...
<template>
<div class="container">
<div class="coursenav flexone">
<div
class="coursenavleft"
:class="selnav == index ? 'selactive' : ''"
:data-id="index"
@click="selectnav"
v-for="(item, index) in navarr"
:key="index"
>
{{ item }}
</div>
</div>
<div class="societybox">
<div class="societyitem">
<div class="societytop flextwo">
<div class="societyleft flexone">
<div class="personimg">
<img src="../../../assets/touxiang.png" alt="" />
</div>
<div class="personright">
<div class="personname">宁立青</div>
<div class="persondate">2020-6-12</div>
</div>
</div>
<div class="dingimg">
<img src="../../../assets/ding.png" alt="" />
</div>
</div>
<div class="societytext">
这个月又瘦了10斤,唐元集真的是太棒了,我 现在自信很多!
</div>
<div class="societyimg flexone">
<div class="societyimgitem">
<img src="../../../assets/societyimg.png" alt="" />
</div>
<div class="societyimgitem">
<img src="../../../assets/societyimg.png" alt="" />
</div>
<div class="societyimgitem">
<img src="../../../assets/societyimg.png" alt="" />
</div>
<div class="societyimgitem">
<img src="../../../assets/societyimg.png" alt="" />
</div>
<div class="societyimgitem">
<img src="../../../assets/societyimg.png" alt="" />
</div>
</div>
<div class="jianzheng flexone">
<div class="jianzhengleft">
#
</div>
<div class="jianzhengright">见证蜕变</div>
</div>
<!-- 点赞 -->
<div class="dainzan flexone">
<div class="flexone dianitem">
<img src="../../../assets/zan.png" alt="" class="dianzanimg" />
<span class="number">960</span>
</div>
<div class="flexone dianitem">
<img src="../../../assets/star.png" alt="" class="dianzanimg" />
<span class="number">960</span>
</div>
<div class="flexone dianitem">
<img src="../../../assets/edit.png" alt="" class="dianzanimg" />
<span class="number">960</span>
</div>
<div class="flexone dianitem">
<img src="../../../assets/download.png" alt="" class="dianzanimg" />
<span class="number">960</span>
</div>
</div>
</div>
</div>
<!-- 图片没有上传 -->
<div class="gantanimg">
<img src="../../../assets/gantan.png" class="ganimg" alt="" />
<div class="gantantext">用户未上传图片</div>
</div>
<tabBar v-bind:active="1" />
</div>
</template>
<script>
import tabBar from "@/components/views/tabBar.vue";
export default {
components: {
tabBar
},
data() {
return {
selnav: 0,
navarr: [
"分类一",
"分类一",
"分类一",
"分类一",
"分类一",
"分类一",
"分类一",
"分类一",
"分类一",
"分类一",
"分类一"
]
};
},
methods: {
selectnav(e) {
this.selnav = e.currentTarget.dataset.id;
}
}
};
</script>
<style scoped>
@import "../../../style/society.css";
</style>
... ...
<template>
<div class="tabbar">
<van-tabbar
v-model="tabbarTempValue"
@change="onChange"
active-color="#599158"
>
<van-tabbar-item>
课堂
<template #icon="props">
<img
class="icon-img"
:src="props.active ? icon.courseactive : icon.course"
/>
</template>
</van-tabbar-item>
<van-tabbar-item
>社区
<template #icon="props">
<img
class="icon-img"
:src="props.active ? icon.shequactive : icon.shequ"
/>
</template>
</van-tabbar-item>
<van-tabbar-item
>活动中心
<template #icon="props">
<img
class="icon-img"
:src="props.active ? icon.societyactive : icon.society"
/>
</template>
</van-tabbar-item>
<van-tabbar-item
>个人中心
<template #icon="props">
<img
class="icon-img"
:src="props.active ? icon.personactive : icon.person"
/>
</template>
</van-tabbar-item>
</van-tabbar>
</div>
</template>
<script>
import Vue from "vue";
import { Tabbar, TabbarItem } from "vant";
import { Icon } from "vant";
import { Notify } from "vant";
Vue.use(Notify);
Vue.use(Tabbar).use(TabbarItem);
Vue.use(Icon);
export default {
props: {
active: Number
},
data() {
return {
tabbarTempValue: this.active,
icon: {
course: require("../../assets/ketang.png"),
courseactive: require("../../assets/ketangactive.png"),
shequ: require("../../assets/shequ.png"),
shequactive: require("../../assets/shequactive.png"),
society: require("../../assets/society.png"),
societyactive: require("../../assets/societyactive.png"),
person: require("../../assets/person.png"),
personactive: require("../../assets/personactive.png")
}
};
},
methods: {
onChange(index) {
const routerArray = ["/", "/society", "/activity", "/usercenter"];
this.$router.push(routerArray[index]);
}
}
};
</script>
<style>
.van-tabbar-item__icon img {
width: 0.54rem;
height: 0.44rem;
}
</style>
... ...
<template>
<div class="container">
<div class="usertop">
<div class="usertophead flextwo">
<div class="usertopheadleft flexone">
<div class="userimg">
<img src="../../../assets/touxiang.png" alt="" />
</div>
<div class="username">欧阳娜娜</div>
</div>
<img src="../../../assets/grayrow.png" alt="" class="yourow" />
</div>
<div class="userlsit flexsix">
<div class="userlistitem flexseven">
<img src="../../../assets/fatiezi.png" alt="" class="userlistimg" />
<div class="iserlistname">发帖子</div>
</div>
<div class="userlistitem flexseven">
<img src="../../../assets/joinus.png" alt="" class="userlistimg" />
<div class="iserlistname">加入我们</div>
</div>
<div class="userlistitem flexseven">
<img src="../../../assets/kefu.png" alt="" class="userlistimg" />
<div class="iserlistname">客服中心</div>
</div>
<div class="userlistitem flexseven">
<img src="../../../assets/jiangquan.png" alt="" class="userlistimg" />
<div class="iserlistname">获得奖券</div>
</div>
<div class="userlistitem flexseven">
<img src="../../../assets/collect.png" alt="" class="userlistimg" />
<div class="iserlistname">我的收藏</div>
</div>
</div>
</div>
<div class="kaikeitem flextwo">
<div class="kaikeitemleft flexone">
<div class="courseimg">
<img src="../../../assets/kaike.png" alt="" />
</div>
<span class="kaiketext">去开课</span>
</div>
<img src="../../../assets/grayrow.png" alt="" class="yourow" />
</div>
<div class="kaikeitem flextwo">
<div class="kaikeitemleft flexone">
<div class="courseimg">
<img src="../../../assets/zuozhan.png" alt="" />
</div>
<span class="kaiketext">作战包</span>
</div>
<img src="../../../assets/grayrow.png" alt="" class="yourow" />
</div>
<div class="kaikeitem flextwo">
<div class="kaikeitemleft flexone">
<div class="courseimg">
<img src="../../../assets/sucai.png" alt="" />
</div>
<span class="kaiketext">素材</span>
</div>
<img src="../../../assets/grayrow.png" alt="" class="yourow" />
</div>
<tabBar v-bind:active="3" />
</div>
</template>
<script>
import tabBar from "@/components/views/tabBar.vue";
export default {
components: {
tabBar
},
data() {
return {
selnav: 3
};
},
methods: {
selcourse(e) {
console.log(37344);
console.log(e);
this.selnav = e.currentTarget.dataset.id;
}
}
};
</script>
<style>
@import "../../../style/usercenter.css";
</style>
... ...
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import App from "./App";
import router from "./router";
import Vant from "vant";
import "vant/lib/index.css";
Vue.use(Vant);
Vue.config.productionTip = false;
/* eslint-disable no-new */
new Vue({
el: "#app",
router,
components: { App },
template: "<App/>"
});
\ No newline at end of file
... ...
import Vue from "vue";
import Router from "vue-router";
// import HelloWorld from '@/components/HelloWorld'
Vue.use(Router);
export default new Router({
routes: [{
path: "/",
name: "course",
meta: { title: "唐元集公众号" },
component: resolve =>
require(["@/components/views/course/course.vue"], resolve)
},
{
path: "/society",
name: "society",
meta: { title: "唐元集公众号" },
component: resolve =>
require(["@/components/views/society/society.vue"], resolve)
},
{
path: "/activity",
name: "activity",
meta: { title: "唐元集公众号" },
component: resolve =>
require(["@/components/views/activity/activity.vue"], resolve)
},
{
path: "/usercenter",
name: "usercenter",
meta: { title: "唐元集公众号" },
component: resolve =>
require(["@/components/views/usercenter/usercenter.vue"], resolve)
}
// {
// path: '/',
// name: 'HelloWorld',
// component: HelloWorld
// }
]
});
\ No newline at end of file
... ...
.courseitem {
padding: 0.24rem 0.32rem;
box-sizing: border-box;
margin-bottom: 0.16rem;
background: #fff;
}
.courseimg {
width: 2.4rem;
height: 1.46rem;
font-size: 0;
flex: 0 0 auto;
}
.coursetitle {
color: #02170b;
font-size: 0.32rem;
font-weight: bold;
width: 4.4rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.zhiimg {
width: 0.34rem;
height: 0.34rem;
}
.zhiname {
color: #e1b16d;
font-size: 0.28rem;
margin-left: 0.06rem;
}
.morepeople {
width: 2.64rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: #666e69;
font-size: 0.28rem;
}
.knowmore {
color: #4d864d;
font-size: 0.28rem;
}
.courseright {
margin-left: 0.16rem;
}
.zhibo {
margin-top: 0.18rem;
}
.know {
margin-top: 0.18rem;
}
/* 头部切换 */
.coursenav {
background: #fff;
margin-top: 0.32rem;
padding: 0.24rem 0;
box-sizing: border-box;
}
.coursenavleft {
color: #b5bfba;
font-size: 0.28rem;
width: 3.75rem;
text-align: center;
}
.selactive {
position: relative;
color: #599158;
}
.selactive::after {
display: block;
content: "";
width: 0.4rem;
height: 0.02rem;
background: #599158;
position: absolute;
bottom: -0.2rem;
left: 50%;
transform: translateX(-50%);
}
/* 课程 */
.coursebox {
display: flex;
flex-wrap: wrap;
padding: 0.24rem 0.28rem;
box-sizing: border-box;
margin-bottom: 1.2rem;
}
.courseboxitem {
width: 3.35rem;
margin-bottom: 0.16rem;
}
.courseboxitem:nth-child(2n) {
margin-left: 0.17rem;
}
.coursenameimg {
width: 3.35rem;
font-size: 0;
}
.coursetext {
width: 3.35rem;
padding: 0.26rem 0.24rem;
box-sizing: border-box;
background: #fff;
}
.coursename {
color: #02170b;
font-size: 0.28rem;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
margin-top: 0.26rem;
}
.courseteacher {
color: #666e69;
font-size: 0.24rem;
margin-top: 0.08rem;
}
.knowlagename {
color: #666e69;
}
\ No newline at end of file
... ...
.coursenav {
width: 100%;
overflow-x: scroll;
background: #fff;
padding: 0.24rem 0.58rem;
box-sizing: border-box;
}
.coursenavleft {
color: #b5bfba;
font-size: 0.28rem;
text-align: center;
flex: 0 0 auto;
margin-right: 0.52rem;
}
.selactive {
position: relative;
color: #599158;
}
.selactive::after {
display: block;
content: "";
width: 0.4rem;
height: 0.02rem;
background: #599158;
position: absolute;
bottom: -0.2rem;
left: 50%;
transform: translateX(-50%);
}
/* 社区盒子 */
.societyitem {
width: 6.86rem;
background: #ffffff;
border-radius: 0.08rem;
box-shadow: 0 0.26rem 0.44rem 0 rgba(49, 144, 49, 0.08);
padding: 0.24rem 0.26rem;
box-sizing: border-box;
margin: 0.32rem auto 0;
}
.societytop {
position: relative;
}
.personimg {
width: 0.8rem;
height: 0.8rem;
font-size: 0;
border-radius: 50%;
}
.personname {
color: #02170b;
font-size: 0.28rem;
}
.persondate {
color: #b5bfba;
font-size: 0.24rem;
}
.dingimg {
width: 0.4rem;
height: 0.6rem;
font-size: 0;
position: absolute;
top: -0.24rem;
right: 0;
}
.personright {
margin-left: 0.16rem;
}
.societytext {
color: #344039;
font-size: 0.32rem;
margin-top: 0.18rem;
}
.societyimg {
flex-wrap: wrap;
margin-top: 0.24rem;
}
.societyimgitem {
width: 2.02rem;
height: 2.02rem;
font-size: 0;
margin-right: 0.09rem;
margin-bottom: 0.16rem;
}
.jianzheng {
width: 1.56rem;
height: 0.44rem;
border-radius: 0.08rem;
font-size: 0.16rem;
line-height: 0.44rem;
margin-top: 0.32rem;
}
.jianzhengleft {
width: 0.36rem;
height: 0.44rem;
background: #5d9a5c;
color: #fff;
text-align: center;
border-radius: 0.08rem 0 0 0.08rem;
}
.jianzhengright {
width: 1.2rem;
height: 0.44rem;
background: #e6ebe6;
text-align: center;
color: #5d9a5c;
border-radius: 0 0.08rem 0.08rem 0;
}
.dianzanimg {
width: 0.32rem;
height: 0.32rem;
font-size: 0;
}
.number {
color: #7b7b7b;
font-size: 0.2rem;
margin-left: 0.18rem;
margin-top: 0.1rem;
}
.dianitem {
margin-right: 0.58rem;
}
.dainzan {
margin-top: 0.26rem;
}
.gantanimg {
width: 2.4rem;
height: 2.4rem;
background: #939496;
border-radius: 0.08rem;
position: absolute;
left: 50%;
top: 50%;
text-align: center;
transform: translateX(-50%);
}
.ganimg {
width: 0.72rem;
height: 0.72rem;
margin-top: 0.58rem;
}
.gantantext {
color: #fff;
font-size: 0.28rem;
text-align: center;
margin-top: 0.16rem;
}
\ No newline at end of file
... ...
.usertop {
padding: 0.32rem;
box-sizing: border-box;
background: #fff;
}
.userimg {
width: 1.52rem;
height: 1.52rem;
}
.username {
color: #323233;
font-size: 0.36rem;
margin-left: 0.32rem;
}
.usertophead {
padding-bottom: 0.32rem;
border-bottom: 1px solid #eee;
}
.userlsit {
padding: 0.35rem 0;
}
.userlistimg {
width: 0.7rem;
height: 0.7rem;
}
.iserlistname {
color: #344039;
font-size: 0.24rem;
text-align: center;
}
.kaikeitem {
padding: 0.32rem;
box-sizing: border-box;
margin-top: 0.16rem;
background: #fff;
}
.courseimg {
width: 0.44rem;
height: 0.44rem;
font-size: 0;
}
.kaiketext {
color: #454e57;
font-size: 0.32rem;
margin-left: 0.16rem;
}
.kaiketext {
color: #454e57;
font-size: 0.32rem;
margin-left: 0.16rem;
}
\ No newline at end of file
... ...
// A custom Nightwatch assertion.
// The assertion name is the filename.
// Example usage:
//
// browser.assert.elementCount(selector, count)
//
// For more information on custom assertions see:
// http://nightwatchjs.org/guide#writing-custom-assertions
exports.assertion = function (selector, count) {
this.message = 'Testing if element <' + selector + '> has count: ' + count
this.expected = count
this.pass = function (val) {
return val === this.expected
}
this.value = function (res) {
return res.value
}
this.command = function (cb) {
var self = this
return this.api.execute(function (selector) {
return document.querySelectorAll(selector).length
}, [selector], function (res) {
cb.call(self, res)
})
}
}
... ...
require('babel-register')
var config = require('../../config')
// http://nightwatchjs.org/gettingstarted#settings-file
module.exports = {
src_folders: ['test/e2e/specs'],
output_folder: 'test/e2e/reports',
custom_assertions_path: ['test/e2e/custom-assertions'],
selenium: {
start_process: true,
server_path: require('selenium-server').path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': require('chromedriver').path
}
},
test_settings: {
default: {
selenium_port: 4444,
selenium_host: 'localhost',
silent: true,
globals: {
devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port)
}
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true
}
}
}
}
... ...
// 1. start the dev server using production config
process.env.NODE_ENV = 'testing'
const webpack = require('webpack')
const DevServer = require('webpack-dev-server')
const webpackConfig = require('../../build/webpack.prod.conf')
const devConfigPromise = require('../../build/webpack.dev.conf')
let server
devConfigPromise.then(devConfig => {
const devServerOptions = devConfig.devServer
const compiler = webpack(webpackConfig)
server = new DevServer(compiler, devServerOptions)
const port = devServerOptions.port
const host = devServerOptions.host
return server.listen(port, host)
})
.then(() => {
// 2. run the nightwatch test suite against it
// to run in additional browsers:
// 1. add an entry in test/e2e/nightwatch.conf.js under "test_settings"
// 2. add it to the --env flag below
// or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
// For more information on Nightwatch's config file, see
// http://nightwatchjs.org/guide#settings-file
let opts = process.argv.slice(2)
if (opts.indexOf('--config') === -1) {
opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
}
if (opts.indexOf('--env') === -1) {
opts = opts.concat(['--env', 'chrome'])
}
const spawn = require('cross-spawn')
const runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
runner.on('exit', function (code) {
server.close()
process.exit(code)
})
runner.on('error', function (err) {
server.close()
throw err
})
})
... ...
// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage
module.exports = {
'default e2e tests': function (browser) {
// automatically uses dev Server port from /config.index.js
// default: http://localhost:8080
// see nightwatch.conf.js
const devServer = browser.globals.devServerURL
browser
.url(devServer)
.waitForElementVisible('#app', 5000)
.assert.elementPresent('.hello')
.assert.containsText('h1', 'Welcome to Your Vue.js App')
.assert.elementCount('img', 1)
.end()
}
}
... ...
{
"env": {
"jest": true
},
"globals": {
}
}
... ...
const path = require('path')
module.exports = {
rootDir: path.resolve(__dirname, '../../'),
moduleFileExtensions: [
'js',
'json',
'vue'
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
},
transform: {
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
'.*\\.(vue)$': '<rootDir>/node_modules/vue-jest'
},
testPathIgnorePatterns: [
'<rootDir>/test/e2e'
],
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
setupFiles: ['<rootDir>/test/unit/setup'],
mapCoverage: true,
coverageDirectory: '<rootDir>/test/unit/coverage',
collectCoverageFrom: [
'src/**/*.{js,vue}',
'!src/main.js',
'!src/router/index.js',
'!**/node_modules/**'
]
}
... ...
import Vue from 'vue'
Vue.config.productionTip = false
... ...
import Vue from 'vue'
import HelloWorld from '@/components/HelloWorld'
describe('HelloWorld.vue', () => {
it('should render correct contents', () => {
const Constructor = Vue.extend(HelloWorld)
const vm = new Constructor().$mount()
expect(vm.$el.querySelector('.hello h1').textContent)
.toEqual('Welcome to Your Vue.js App')
})
})
... ...