Yeah, it should be charged per kWh, which is the equivalent of gallons/litres we use for gasoline. The cars track how many kWh they use and the charge interface includes communication which is usually bidirectional, smart meters would record the kWh from the vehicle charging and public charging would automatically include the fee. So, if you charge at home, it's on your electricity bill, if you public charge, it's part of what you pay.
Like with gas, this avoids having to track the # of miles, it's tied to efficiency, which naturally includes weight, which means wear and tear on the roads. A heavier car will consume more power in use; use more kWh per drive cycle, resulting in more tax being collected and the inverse for lighter cars.