Note: based on alibaba aplus data framework, only support aplus traceless goldlog, and is strongly dependent on React !!
npm install --save-dev spm-loader
module.exports = {
module: {
rules: [{
test: /.\jsx?$/,
use: [
'babel-loader',
'spm-loader?goldlog=/aliyun&context=spm_self&key=spmKey'
]
}]
}
}
The loader just replace the attribute spm-auto-click
to standard traceless goldlog, for example data-spm-click="gostr=/aliyun;locaid=d1"
.
To verify locaid is unique, we compose it using three components, the filename, the module key and the iteration sequence.
So, our final locaid would be locaid=d{filename}{key}{seq}
. See more in our examples.
<div spm-auto-click /> // => <div data-spm-click="gostr=/aliyun;locaid=d{filename}{key||''}" />
<div spm-auto-click={1}> // => <div data-spm-click="gostr=/aliyun;locaid=d{filename}{key||''}1" />
Traceless goldlog key. You should apply it in the spm center, start with /
, default is /aliyun
.
In jsx, we use context
as the context of any iteration, so we can get properties in iteration, default is spm_self
.
A module can be used many times in a parent module, but the traceless goldlog key must be unique, so key
is used to identity a module, default is spmKey
.